Index: gdb/testsuite/gdb.base/catch-signal-fork.c |
diff --git a/gdb/testsuite/gdb.base/signest.c b/gdb/testsuite/gdb.base/catch-signal-fork.c |
similarity index 61% |
copy from gdb/testsuite/gdb.base/signest.c |
copy to gdb/testsuite/gdb.base/catch-signal-fork.c |
index 1a9c1cea066cacd4c5e1ff68129f177f6ee0de7f..9c316d3ff6618f3d5e59e5669afd5f6f3e804eb4 100644 |
--- a/gdb/testsuite/gdb.base/signest.c |
+++ b/gdb/testsuite/gdb.base/catch-signal-fork.c |
@@ -1,6 +1,6 @@ |
/* This testcase is part of GDB, the GNU debugger. |
- Copyright 2011-2012 Free Software Foundation, Inc. |
+ Copyright 2012-2013 Free Software Foundation, Inc. |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
@@ -14,40 +14,45 @@ |
You should have received a copy of the GNU General Public License |
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
- |
-#include <signal.h> |
#include <stdlib.h> |
-#include <string.h> |
+#include <signal.h> |
#include <unistd.h> |
-volatile char *p = NULL; |
- |
-extern long |
-bowler (void) |
+void |
+do_nothing (void) |
{ |
- return *p; |
} |
-extern void |
-keeper (int sig) |
+void |
+handle (int sig) |
{ |
- static int recurse = 0; |
- if (++recurse < 3) |
- bowler (); |
- |
- _exit (0); |
+ do_nothing (); /* handle marker */ |
} |
int |
-main (void) |
+main () |
{ |
- struct sigaction act; |
- memset (&act, 0, sizeof act); |
- act.sa_handler = keeper; |
- act.sa_flags = SA_NODEFER; |
- sigaction (SIGSEGV, &act, NULL); |
- sigaction (SIGBUS, &act, NULL); |
- |
- bowler (); |
- return 0; |
+ int i; |
+ signal (SIGHUP, handle); |
+ |
+ raise (SIGHUP); /* first HUP */ |
+ |
+ signal (SIGCHLD, handle); |
+ for (i = 0; i < 3; i++) /* fork loop */ |
+ { |
+ switch (fork()) |
+ { |
+ case -1: |
+ perror ("fork"); |
+ exit (1); |
+ case 0: |
+ exit (0); |
+ } |
+ wait (NULL); |
+ } |
+ |
+ raise (SIGHUP); /* second HUP */ |
+ |
+ raise (SIGHUP); /* third HUP */ |
} |
+ |