summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-04-16 22:54:36 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-04-16 22:54:36 -0700
commitada08e1b0c7d8d61dc59cadb5eefd665522d149a (patch)
tree1b8d9de95e9f4332c0e0a1e4cdba824bd5f4453c /sysif.c
parentc5d0fdcd677e46b7536a47812e63a1460559fd1c (diff)
downloadtxr-ada08e1b0c7d8d61dc59cadb5eefd665522d149a.tar.gz
txr-ada08e1b0c7d8d61dc59cadb5eefd665522d149a.tar.bz2
txr-ada08e1b0c7d8d61dc59cadb5eefd665522d149a.zip
Adding exit* function which calls _exit.
* sysif.c (exit_star_wrap): New static function. (sysif_init): Registered exit* intrinsic. * txr.1: Documented exit*. * tl.vim, txr.vim: Regenerated.
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sysif.c b/sysif.c
index 4cbe6f16..8f659ced 100644
--- a/sysif.c
+++ b/sysif.c
@@ -497,6 +497,22 @@ static val exec_wrap(val file, val args_opt)
uw_throwf(file_error_s, lit("execvp ~a returned"), file, nao);
}
+static val exit_star_wrap(val status)
+{
+ int stat;
+
+ if (status == nil)
+ stat = EXIT_FAILURE;
+ else if (status == t)
+ stat = EXIT_SUCCESS;
+ else
+ stat = c_num(status);
+
+ _exit(stat);
+ /* notreached */
+ return nil;
+}
+
#endif
#if HAVE_SYS_STAT
@@ -690,6 +706,7 @@ void sysif_init(void)
reg_fun(intern(lit("fork"), user_package), func_n0(fork_wrap));
reg_fun(intern(lit("wait"), user_package), func_n2o(wait_wrap, 0));
reg_fun(intern(lit("exec"), user_package), func_n2o(exec_wrap, 1));
+ reg_fun(intern(lit("exit*"), user_package), func_n1(exit_star_wrap));
reg_fun(intern(lit("w-ifexited"), user_package), func_n1(wifexited));
reg_fun(intern(lit("w-exitstatus"), user_package), func_n1(wexitstatus));
reg_fun(intern(lit("w-ifsignaled"), user_package), func_n1(wifsignaled));