1 /* sigset_SIG_HOLD_bug.c [BZ #1951] */
10 #include <sys/types.h>
12 #include <libc-diag.h>
14 /* The sigset function is deprecated. */
15 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
17 #define TEST_SIG SIGINT
20 /* Print mask of blocked signals for this process */
22 printSigMask (const char *msg)
31 if (sigprocmask (SIG_BLOCK, NULL, &currMask) == -1)
32 error (1, errno, "sigaction");
35 for (sig = 1; sig < NSIG; sig++)
37 if (sigismember (&currMask, sig))
40 printf ("\t\t%d (%s)\n", sig, strsignal (sig));
45 printf ("\t\t<empty signal set>\n");
51 printf ("Caught signal %d\n", sig);
52 printSigMask ("Signal mask in handler\n");
53 printf ("Handler returning\n");
58 printDisposition (sighandler_t disp)
62 else if (disp == SIG_DFL)
64 else if (disp == SIG_IGN)
67 printf ("handled at %" PRIxPTR, (uintptr_t) disp);
68 } /* printDisposition */
75 printf ("===== TEST 1 =====\n");
76 printf ("Blocking signal with sighold()\n");
77 if (sighold (TEST_SIG) == -1)
78 error (1, errno, "sighold");
79 printSigMask ("Signal mask after sighold()\n");
81 printf ("About to use sigset() to establish handler\n");
82 prev = sigset (TEST_SIG, handler);
84 error(1, errno, "sigset");
86 printf ("Previous disposition: ");
87 printDisposition (prev);
88 printf (" (should be SIG_HOLD)\n");
91 printf("TEST FAILED!!!\n");
102 printf ("\n===== TEST 2 =====\n");
104 printf ("About to use sigset() to set SIG_HOLD\n");
105 prev = sigset (TEST_SIG, SIG_HOLD);
107 error (1, errno, "sigset");
109 printf ("Previous disposition: ");
110 printDisposition (prev);
111 printf (" (should be SIG_DFL)\n");
114 printf("TEST FAILED!!!\n");
125 printf ("\n===== TEST 3 =====\n");
127 printf ("About to use sigset() to set SIG_HOLD\n");
128 prev = sigset (TEST_SIG, SIG_HOLD);
130 error (1, errno, "sigset");
132 printf ("About to use sigset() to set SIG_HOLD (again)\n");
133 prev = sigset (TEST_SIG, SIG_HOLD);
135 error (1, errno, "sigset");
137 printf ("Previous disposition: ");
138 printDisposition (prev);
139 printf (" (should be SIG_HOLD)\n");
140 if (prev != SIG_HOLD)
142 printf("TEST FAILED!!!\n");
149 main (int argc, char *argv[])
155 error (1, errno, "fork");
158 exit (returnTest1 ());
161 if (TEMP_FAILURE_RETRY (waitpid (childPid, &status, 0)) != childPid)
162 error (1, errno, "waitpid");
163 int result = !WIFEXITED (status) || WEXITSTATUS (status) != 0;
167 error (1, errno, "fork");
170 exit (returnTest2 ());
172 if (TEMP_FAILURE_RETRY (waitpid (childPid, &status, 0)) != childPid)
173 error (1, errno, "waitpid");
174 result |= !WIFEXITED (status) || WEXITSTATUS (status) != 0;
178 error (1, errno, "fork");
181 exit (returnTest3 ());
183 if (TEMP_FAILURE_RETRY (waitpid (childPid, &status, 0)) != childPid)
184 error (1, errno, "waitpid");
185 result |= !WIFEXITED (status) || WEXITSTATUS (status) != 0;