summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-01-23 22:06:52 -0800
committerKaz Kyheku <kaz@kylheku.com>2020-01-23 22:06:52 -0800
commit208319c21734bbb829fd6b8e2bc9da819b454bad (patch)
tree52b37dfbf2ab6ab24fc5758ae6ca75b663112f93 /sysif.c
parente2b37f659246bf9c5ba2ed9561772f8b56a36256 (diff)
downloadtxr-208319c21734bbb829fd6b8e2bc9da819b454bad.tar.gz
txr-208319c21734bbb829fd6b8e2bc9da819b454bad.tar.bz2
txr-208319c21734bbb829fd6b8e2bc9da819b454bad.zip
New function: mkfifo.
* configure: detect mkfifo. (sysif_init): Register mkfifo intrinsic. * txr.1: Documented.
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c25
1 files changed, 25 insertions, 0 deletions
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