ref: af064114fd7e744e3af0cc67478aab670b5d13c6
parent: 5cade7073c5e1ed971b525e49c3c0dd43d6a9feb
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Mar 15 09:17:53 EDT 2021
add sigaction
--- a/libnpe/mkfile
+++ b/libnpe/mkfile
@@ -24,6 +24,7 @@
readdir.$O\
rename.$O\
round.$O\
+ sigaction.$O\
stat.$O\
trunc.$O\
usleep.$O\
--- /dev/null
+++ b/libnpe/sigaction.c
@@ -1,0 +1,25 @@
+#include <signal.h>
+
+/* FIXME this only supports a single handler */
+
+static sa_handler last;
+
+static int
+handler(void*, char *s)
+{
+ /* kill is kill */
+ if(strcmp(s, "kill") != 0 && strcmp(s, "threadint") != 0)
+ last(SIGSEGV);
+ return 0;
+}
+
+void
+sigaction(int, struct sigaction *act, struct sigaction *)
+{
+ if(act != nil && last == nil){
+ last = act->sa_handler;
+ atnotify(handler, 1);
+ }else if(act == nil){
+ atnotify(handler, 0);
+ }
+}