summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-04-11 07:13:24 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-04-11 07:13:24 -0700
commit2db685dba6db27f92767ae5f16f62744fcb604ac (patch)
treeddf11ccc5d3fa2d1a8b3a04291d6d49e405ca12a /sysif.c
parent6a350fd788f3114629c9993aa4d1ec5c292182f5 (diff)
downloadtxr-2db685dba6db27f92767ae5f16f62744fcb604ac.tar.gz
txr-2db685dba6db27f92767ae5f16f62744fcb604ac.tar.bz2
txr-2db685dba6db27f92767ae5f16f62744fcb604ac.zip
Exposing dup and dup2.
* sysif.c (dup_wrap): New static function. (sysif_init): Register dup_wrap as dupfd. The name dup conflicts with an existing function. * txr.1: Documented dupfd. * txr.vim, tl.vim: Regenerated.
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sysif.c b/sysif.c
index 545992b5..bee235dd 100644
--- a/sysif.c
+++ b/sysif.c
@@ -454,6 +454,13 @@ static val wifcontinued(val status)
}
#endif
+static val dup_wrap(val old, val new)
+{
+ if (missingp(new))
+ return num(dup(c_num(old)));
+ return num(dup2(c_num(old), c_num(new)));
+}
+
#endif
#if HAVE_SYS_STAT
@@ -651,5 +658,6 @@ void sysif_init(void)
#ifdef WCONTINUED
reg_var(intern(lit("w-continued"), user_package), num_fast(WCONTINUED));
#endif
+ reg_fun(intern(lit("dupfd"), user_package), func_n2o(dup_wrap, 1));
#endif
}