aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2006-01-01 17:26:52 +0000
committerChristopher Faylor <me@cgf.cx>2006-01-01 17:26:52 +0000
commit031d1aa40f8e7971e946ff49cf9147392871ae0a (patch)
treeecfbaad0db63c50b9e326d6d5666280af9dc99da
parent4eab146fc7e6e1bf73fba64bac39c954b11954f9 (diff)
downloadnewlib-031d1aa40f8e7971e946ff49cf9147392871ae0a.zip
newlib-031d1aa40f8e7971e946ff49cf9147392871ae0a.tar.gz
newlib-031d1aa40f8e7971e946ff49cf9147392871ae0a.tar.bz2
* winsup.api/resethand.c: New file.
-rw-r--r--winsup/testsuite/ChangeLog4
-rw-r--r--winsup/testsuite/winsup.api/resethand.c35
2 files changed, 39 insertions, 0 deletions
diff --git a/winsup/testsuite/ChangeLog b/winsup/testsuite/ChangeLog
index 66944c0..5c45503 100644
--- a/winsup/testsuite/ChangeLog
+++ b/winsup/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2006-01-01 Christopher Faylor <cgf@timesys.com>
+
+ * winsup.api/resethand.c: New file.
+
2005-12-11 Christopher Faylor <cgf@timesys.com>
* winsup.api/ltp/dup03.c (cleanup): Fix longstanding off-by-one error
diff --git a/winsup/testsuite/winsup.api/resethand.c b/winsup/testsuite/winsup.api/resethand.c
new file mode 100644
index 0000000..c8b92b2
--- /dev/null
+++ b/winsup/testsuite/winsup.api/resethand.c
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int doit = 0;
+void
+ouch (int sig)
+{
+ fprintf (stderr, "ouch %d\n", sig);
+ if (doit++ == 0)
+ kill (getpid (), SIGTERM);
+}
+
+int
+main (int argc, char **argv)
+{
+ static struct sigaction act;
+ if (argc == 1)
+ act.sa_flags = SA_RESETHAND;
+ act.sa_handler = ouch;
+ sigaction (SIGTERM, &act, NULL);
+ int pid = fork ();
+ int status;
+ if (pid > 0)
+ waitpid (pid, &status, 0);
+ else
+ {
+ kill (getpid (), SIGTERM);
+ exit (0x27);
+ }
+ fprintf (stderr, "pid %d exited with status %p\n", pid, status);
+ exit (argc == 1 ? !(status == SIGTERM) : !(status == 0x2700));
+}