1 /* sigset_SIG_HOLD_bug.c [BZ #1951] */
10 #include <sys/types.h>
13 #define TEST_SIG SIGINT
16 /* Print mask of blocked signals for this process */
18 printSigMask (const char *msg
)
27 if (sigprocmask (SIG_BLOCK
, NULL
, &currMask
) == -1)
28 error (1, errno
, "sigaction");
31 for (sig
= 1; sig
< NSIG
; sig
++)
33 if (sigismember (&currMask
, sig
))
36 printf ("\t\t%d (%s)\n", sig
, strsignal (sig
));
41 printf ("\t\t<empty signal set>\n");
47 printf ("Caught signal %d\n", sig
);
48 printSigMask ("Signal mask in handler\n");
49 printf ("Handler returning\n");
54 printDisposition (sighandler_t disp
)
58 else if (disp
== SIG_DFL
)
60 else if (disp
== SIG_IGN
)
63 printf ("handled at %" PRIxPTR
, (uintptr_t) disp
);
64 } /* printDisposition */
71 printf ("===== TEST 1 =====\n");
72 printf ("Blocking signal with sighold()\n");
73 if (sighold (TEST_SIG
) == -1)
74 error (1, errno
, "sighold");
75 printSigMask ("Signal mask after sighold()\n");
77 printf ("About to use sigset() to establish handler\n");
78 prev
= sigset (TEST_SIG
, handler
);
80 error(1, errno
, "sigset");
82 printf ("Previous disposition: ");
83 printDisposition (prev
);
84 printf (" (should be SIG_HOLD)\n");
87 printf("TEST FAILED!!!\n");
98 printf ("\n===== TEST 2 =====\n");
100 printf ("About to use sigset() to set SIG_HOLD\n");
101 prev
= sigset (TEST_SIG
, SIG_HOLD
);
103 error (1, errno
, "sigset");
105 printf ("Previous disposition: ");
106 printDisposition (prev
);
107 printf (" (should be SIG_DFL)\n");
110 printf("TEST FAILED!!!\n");
121 printf ("\n===== TEST 3 =====\n");
123 printf ("About to use sigset() to set SIG_HOLD\n");
124 prev
= sigset (TEST_SIG
, SIG_HOLD
);
126 error (1, errno
, "sigset");
128 printf ("About to use sigset() to set SIG_HOLD (again)\n");
129 prev
= sigset (TEST_SIG
, SIG_HOLD
);
131 error (1, errno
, "sigset");
133 printf ("Previous disposition: ");
134 printDisposition (prev
);
135 printf (" (should be SIG_HOLD)\n");
136 if (prev
!= SIG_HOLD
)
138 printf("TEST FAILED!!!\n");
145 main (int argc
, char *argv
[])
151 error (1, errno
, "fork");
154 exit (returnTest1 ());
157 if (TEMP_FAILURE_RETRY (waitpid (childPid
, &status
, 0)) != childPid
)
158 error (1, errno
, "waitpid");
159 int result
= !WIFEXITED (status
) || WEXITSTATUS (status
) != 0;
163 error (1, errno
, "fork");
166 exit (returnTest2 ());
168 if (TEMP_FAILURE_RETRY (waitpid (childPid
, &status
, 0)) != childPid
)
169 error (1, errno
, "waitpid");
170 result
|= !WIFEXITED (status
) || WEXITSTATUS (status
) != 0;
174 error (1, errno
, "fork");
177 exit (returnTest3 ());
179 if (TEMP_FAILURE_RETRY (waitpid (childPid
, &status
, 0)) != childPid
)
180 error (1, errno
, "waitpid");
181 result
|= !WIFEXITED (status
) || WEXITSTATUS (status
) != 0;