2 * Copyright 2007, Vasilis Kaoutsis, kaoutsis@sch.gr
3 * Distributed under the terms of the MIT License.
9 #include <symbol_versioning.h>
11 #include <signal_private.h>
15 __sigset_beos(int signal
, __sighandler_t signalHandler
)
18 struct sigaction_beos newAction
;
19 newAction
.sa_handler
= signalHandler
;
20 newAction
.sa_flags
= 0;
21 if (signal
== SIGCHLD
&& signalHandler
== SIG_IGN
) {
22 // In case of SIGCHLD the specification requires SA_NOCLDWAIT behavior.
23 newAction
.sa_flags
|= SA_NOCLDWAIT
;
25 newAction
.sa_mask
= 0;
28 struct sigaction_beos oldAction
;
29 if (__sigaction_beos(signal
,
30 signalHandler
== SIG_HOLD
? NULL
: &newAction
, &oldAction
) == -1) {
34 // prepare new signal mask
35 sigset_t_beos newSet
= 0;
36 __sigaddset_beos(&newSet
, signal
);
40 if (signalHandler
== SIG_HOLD
) {
41 if (__pthread_sigmask_beos(SIG_BLOCK
, &newSet
, &oldSet
) == -1)
44 // Disposition is not equal to SIG_HOLD, so sig will be removed from the
45 // calling process' signal mask.
46 if (__pthread_sigmask_beos(SIG_UNBLOCK
, &newSet
, &oldSet
) == -1)
50 return __sigismember_beos(&oldSet
, signal
)
51 ? SIG_HOLD
: oldAction
.sa_handler
;
56 __sigset(int signal
, __sighandler_t signalHandler
)
59 struct sigaction newAction
;
60 newAction
.sa_handler
= signalHandler
;
61 newAction
.sa_flags
= 0;
62 if (signal
== SIGCHLD
&& signalHandler
== SIG_IGN
) {
63 // In case of SIGCHLD the specification requires SA_NOCLDWAIT behavior.
64 newAction
.sa_flags
|= SA_NOCLDWAIT
;
66 newAction
.sa_mask
= 0;
69 struct sigaction oldAction
;
70 if (__sigaction(signal
,
71 signalHandler
== SIG_HOLD
? NULL
: &newAction
, &oldAction
) == -1) {
75 // prepare new signal mask
77 sigaddset(&newSet
, signal
);
81 if (signalHandler
== SIG_HOLD
) {
82 if (sigprocmask(SIG_BLOCK
, &newSet
, &oldSet
) == -1)
85 // Disposition is not equal to SIG_HOLD, so sig will be
86 // removed from the calling process' signal mask.
87 if (sigprocmask(SIG_UNBLOCK
, &newSet
, &oldSet
) == -1)
91 return sigismember(&oldSet
, signal
) ? SIG_HOLD
: oldAction
.sa_handler
;
95 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigset_beos", "sigset@", "BASE");
97 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigset", "sigset@@", "1_ALPHA4");