1 /* Signal handler and mask set in thread which calls exec.
2 Copyright (C) 2003-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
24 #include <support/xsignal.h>
29 /* Ignore SIGUSR1 and block SIGUSR2. */
30 xsignal (SIGUSR1
, SIG_IGN
);
34 sigaddset (&ss
, SIGUSR2
);
35 if (pthread_sigmask (SIG_BLOCK
, &ss
, NULL
) != 0)
37 puts ("1st run: sigmask failed");
41 char **oldargv
= (char **) arg
;
43 while (oldargv
[n
] != NULL
)
46 char **argv
= (char **) alloca ((n
+ 1) * sizeof (char *));
47 for (n
= 0; oldargv
[n
+ 1] != NULL
; ++n
)
48 argv
[n
] = oldargv
[n
+ 1];
49 argv
[n
++] = (char *) "--direct";
52 execv (argv
[0], argv
);
54 puts ("execv failed");
61 do_test (int argc
, char *argv
[])
65 /* This is the second call. Perform the test. */
68 if (sigaction (SIGUSR1
, NULL
, &sa
) != 0)
70 puts ("2nd run: sigaction failed");
73 if (sa
.sa_handler
!= SIG_IGN
)
75 puts ("SIGUSR1 not ignored");
80 if (pthread_sigmask (SIG_SETMASK
, NULL
, &ss
) != 0)
82 puts ("2nd run: sigmask failed");
85 if (! sigismember (&ss
, SIGUSR2
))
87 puts ("SIGUSR2 not blocked");
95 if (pthread_create (&th
, NULL
, tf
, argv
) != 0)
97 puts ("create failed");
101 /* This call should never return. */
102 pthread_join (th
, NULL
);
104 puts ("join returned");
109 #define TEST_FUNCTION do_test (argc, argv)
110 #include "../test-skeleton.c"