summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure21
-rw-r--r--sysif.c25
-rw-r--r--txr.127
3 files changed, 73 insertions, 0 deletions
diff --git a/configure b/configure
index c3b84a64..69a69e57 100755
--- a/configure
+++ b/configure
@@ -2386,6 +2386,27 @@ else
printf "no\n"
fi
+printf "Checking for mkfifo ... "
+
+cat > conftest.c <<!
+#include "config.h"
+#if HAVE_SYS_STAT
+#include <sys/stat.h>
+#endif
+
+int main(void)
+{
+ int e = mkfifo("a", 0);
+ return 0;
+}
+!
+if conftest ; then
+ printf "yes\n"
+ printf "#define HAVE_MKFIFO 1\n" >> config.h
+else
+ printf "no\n"
+fi
+
printf "Checking for chmod/fchmod ... "
cat > conftest.c <<!
#include <sys/stat.h>
diff --git a/sysif.c b/sysif.c
index 4fd4657f..dbaf8e59 100644
--- a/sysif.c
+++ b/sysif.c
@@ -455,6 +455,27 @@ static val mknod_wrap(val path, val mode, val dev)
#endif
+#if HAVE_MKFIFO
+
+static val mkfifo_wrap(val path, val mode)
+{
+ cnum cmode = c_num(mode);
+ char *u8path = utf8_dup_to(c_str(path));
+ int err = mkfifo(u8path, cmode);
+ free(u8path);
+
+ if (err < 0) {
+ int eno = errno;
+ uw_throwf(errno_to_file_error(eno), lit("mknod ~a ~a: ~d/~s"),
+ path, mode, num(eno),
+ string_utf8(strerror(eno)), nao);
+ }
+
+ return t;
+}
+
+#endif
+
#if HAVE_CHMOD || HAVE_SYS_STAT || HAVE_FILE_STAMP_CHANGE
static int get_fd(val stream, val self)
{
@@ -2057,6 +2078,10 @@ void sysif_init(void)
reg_fun(intern(lit("mknod"), user_package), func_n3o(mknod_wrap, 2));
#endif
+#if HAVE_MKFIFO
+ reg_fun(intern(lit("mkfifo"), user_package), func_n2(mkfifo_wrap));
+#endif
+
#if HAVE_CHMOD
reg_fun(intern(lit("chmod"), user_package), func_n2(chmod_wrap));
#endif
diff --git a/txr.1 b/txr.1
index 950b3eac..778d9994 100644
--- a/txr.1
+++ b/txr.1
@@ -58138,6 +58138,33 @@ function.
(mknod "dev/foo" (logior #o700 s-ifchr) (makedev 8 3))
.brev
+.coNP Function @ mkfifo
+.synb
+.mets (mkfifo < path << mode )
+.syne
+.desc
+The
+.code mkfifo
+function creates a POSIX FIFO object.
+If it is successful,
+it returns
+.codn t ,
+otherwise it throws an exception of type
+.codn file-error .
+
+The
+.meta mode
+argument is a bitwise or combination of the requested permissions,
+and is subject to the system
+.codn umask .
+
+Note: the
+.code mknod
+function can also create FIFOs, specified via the bitwise combination
+of the
+.code s-ififo
+type and the permission mode bits.
+
.coNP Functions @ symlink and @ link
.synb
.mets (symlink < target << path )