1 /* sigset_SIG_HOLD_bug.c [BZ #1951] */
10 #include <sys/types.h>
12 #include <libc-diag.h>
14 #include <support/xsignal.h>
16 /* The sigset function is deprecated. */
17 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
19 #define TEST_SIG SIGINT
22 /* Print mask of blocked signals for this process */
24 printSigMask (const char *msg
)
33 if (sigprocmask (SIG_BLOCK
, NULL
, &currMask
) == -1)
34 error (1, errno
, "sigaction");
37 for (sig
= 1; sig
< NSIG
; sig
++)
39 if (sigismember (&currMask
, sig
))
42 printf ("\t\t%d (%s)\n", sig
, strsignal (sig
));
47 printf ("\t\t<empty signal set>\n");
53 printf ("Caught signal %d\n", sig
);
54 printSigMask ("Signal mask in handler\n");
55 printf ("Handler returning\n");
60 printDisposition (sighandler_t disp
)
64 else if (disp
== SIG_DFL
)
66 else if (disp
== SIG_IGN
)
69 printf ("handled at %" PRIxPTR
, (uintptr_t) disp
);
70 } /* printDisposition */
77 printf ("===== TEST 1 =====\n");
78 printf ("Blocking signal with sighold()\n");
79 if (sighold (TEST_SIG
) == -1)
80 error (1, errno
, "sighold");
81 printSigMask ("Signal mask after sighold()\n");
83 printf ("About to use sigset() to establish handler\n");
84 prev
= sigset (TEST_SIG
, handler
);
86 error(1, errno
, "sigset");
88 printf ("Previous disposition: ");
89 printDisposition (prev
);
90 printf (" (should be SIG_HOLD)\n");
93 printf("TEST FAILED!!!\n");
104 printf ("\n===== TEST 2 =====\n");
106 printf ("About to use sigset() to set SIG_HOLD\n");
107 prev
= sigset (TEST_SIG
, SIG_HOLD
);
109 error (1, errno
, "sigset");
111 printf ("Previous disposition: ");
112 printDisposition (prev
);
113 printf (" (should be SIG_DFL)\n");
116 printf("TEST FAILED!!!\n");
127 printf ("\n===== TEST 3 =====\n");
129 printf ("About to use sigset() to set SIG_HOLD\n");
130 prev
= sigset (TEST_SIG
, SIG_HOLD
);
132 error (1, errno
, "sigset");
134 printf ("About to use sigset() to set SIG_HOLD (again)\n");
135 prev
= sigset (TEST_SIG
, SIG_HOLD
);
137 error (1, errno
, "sigset");
139 printf ("Previous disposition: ");
140 printDisposition (prev
);
141 printf (" (should be SIG_HOLD)\n");
142 if (prev
!= SIG_HOLD
)
144 printf("TEST FAILED!!!\n");
151 main (int argc
, char *argv
[])
153 xsignal (TEST_SIG
, SIG_DFL
);
159 error (1, errno
, "fork");
162 exit (returnTest1 ());
165 if (TEMP_FAILURE_RETRY (waitpid (childPid
, &status
, 0)) != childPid
)
166 error (1, errno
, "waitpid");
167 int result
= !WIFEXITED (status
) || WEXITSTATUS (status
) != 0;
171 error (1, errno
, "fork");
174 exit (returnTest2 ());
176 if (TEMP_FAILURE_RETRY (waitpid (childPid
, &status
, 0)) != childPid
)
177 error (1, errno
, "waitpid");
178 result
|= !WIFEXITED (status
) || WEXITSTATUS (status
) != 0;
182 error (1, errno
, "fork");
185 exit (returnTest3 ());
187 if (TEMP_FAILURE_RETRY (waitpid (childPid
, &status
, 0)) != childPid
)
188 error (1, errno
, "waitpid");
189 result
|= !WIFEXITED (status
) || WEXITSTATUS (status
) != 0;