summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure19
-rw-r--r--sysif.c17
-rw-r--r--txr.110
3 files changed, 46 insertions, 0 deletions
diff --git a/configure b/configure
index 7ea5bea0..c2c599f5 100755
--- a/configure
+++ b/configure
@@ -2397,6 +2397,25 @@ else
printf "no\n"
fi
+printf "Checking for strsignal ... "
+
+cat > conftest.c <<!
+#include <string.h>
+#include <signal.h>
+
+int main(void)
+{
+ const char *s = strsignal(SIGABRT);
+ return 0;
+}
+!
+if conftest ; then
+ printf "yes\n"
+ printf "#define HAVE_STRSIGNAL 1\n" >> config.h
+else
+ printf "no\n"
+fi
+
printf "Checking for setitimer/getitimer ... "
cat > conftest.c <<!
diff --git a/sysif.c b/sysif.c
index e54d6c5f..7d383162 100644
--- a/sysif.c
+++ b/sysif.c
@@ -161,6 +161,20 @@ static val strerror_wrap(val errnum)
return errno_to_str(eno);
}
+#if HAVE_STRSIGNAL
+
+static val strsignal_wrap(val signum)
+{
+ val self = lit("strsignal");
+ int sig = c_int(signum, self);
+ const char *str = strsignal(sig);
+ return if3(str,
+ string_utf8(strsignal(sig)),
+ format(nil, lit("Unknown signal %s"), signum, nao));
+}
+
+#endif
+
#if HAVE_DAEMON
static val daemon_wrap(val nochdir, val noclose)
{
@@ -2350,6 +2364,9 @@ void sysif_init(void)
reg_fun(intern(lit("errno"), user_package), func_n1o(errno_wrap, 0));
reg_fun(intern(lit("strerror"), user_package), func_n1o(strerror_wrap, 0));
+#if HAVE_STRSIGNAL
+ reg_fun(intern(lit("strsignal"), user_package), func_n1(strsignal_wrap));
+#endif
reg_fun(intern(lit("exit"), user_package), func_n1o(exit_wrap, 0));
reg_fun(intern(lit("at-exit-call"), user_package), func_n1(at_exit_call));
reg_fun(intern(lit("at-exit-do-not-call"), user_package), func_n1(at_exit_do_not_call));
diff --git a/txr.1 b/txr.1
index 597c0723..84b1dab7 100644
--- a/txr.1
+++ b/txr.1
@@ -60916,6 +60916,16 @@ The return value is
if the function succeeds, otherwise
.codn nil .
+.coNP Function @ strsignal
+.synb
+.mets (strsignal << signal )
+.syne
+.desc
+The
+.code strsignal
+function returns a character string describing the specified signal number.
+It is based on the same-named POSIX C library function.
+
.SS* Unix Processes
.coNP Functions @ fork and @ wait