7 /* POSIX signal handling compatibility
9 /* #include <posix_signals.h>
14 /* int sigaddset(set, signum)
18 /* int sigprocmask(how, set, old)
23 /* int sigaction(sig, act, oact)
25 /* struct sigaction *act;
26 /* struct sigaction *oact;
28 /* These routines emulate the POSIX signal handling interface.
30 /* Pieter Schoenmakers
31 /* Eindhoven University of Technology
45 #include "posix_signals.h"
47 #ifdef MISSING_SIGSET_T
49 int sigemptyset(sigset_t
*m
)
54 int sigaddset(sigset_t
*set
, int signum
)
56 *set
|= sigmask(signum
);
60 int sigprocmask(int how
, sigset_t
*set
, sigset_t
*old
)
65 previous
= sigblock(*set
);
66 else if (how
== SIG_SETMASK
)
67 previous
= sigsetmask(*set
);
68 else if (how
== SIG_UNBLOCK
) {
71 previous
= sigsetmask(m
& ~*set
);
84 #ifdef MISSING_SIGACTION
86 static struct sigaction actions
[NSIG
] = {};
88 static int sighandle(int signum
)
90 if (signum
== SIGCHLD
) {
91 /* XXX If the child is just stopped, don't invoke the handler. */
93 actions
[signum
].sa_handler(signum
);
96 int sigaction(int sig
, struct sigaction
*act
, struct sigaction
*oact
)
98 static int initialized
= 0;
103 for (i
= 0; i
< NSIG
; i
++)
104 actions
[i
].sa_handler
= SIG_DFL
;
107 if (sig
<= 0 || sig
>= NSIG
) {
112 *oact
= actions
[sig
];
115 struct sigvec mine
= {
116 sighandle
, act
->sa_mask
,
117 act
->sa_flags
& SA_RESTART
? SV_INTERRUPT
: 0
120 if (sigvec(sig
, &mine
, NULL
))