Unignore signals when starting CloudABI processes.
As CloudABI processes cannot adjust their signal handlers, we need to make sure that we start up CloudABI processes with consistent signal masks. Though the POSIx standard signal behavior is all right, we do need to make sure that we ignore SIGPIPE, as it would otherwise be hard to interact with pipes and sockets. Extend execsigs() to iterate over ps_sigignore and call sigdflt() for each of the ignored signals. Reviewed by: kib Obtained from: https://github.com/NuxiNL/freebsd Differential Revision: https://reviews.freebsd.org/D3365
This commit is contained in:
parent
2c20fbe43a
commit
f3fe76ecd8
@ -952,6 +952,7 @@ sigdflt(struct sigacts *ps, int sig)
|
||||
void
|
||||
execsigs(struct proc *p)
|
||||
{
|
||||
sigset_t osigignore;
|
||||
struct sigacts *ps;
|
||||
int sig;
|
||||
struct thread *td;
|
||||
@ -971,6 +972,24 @@ execsigs(struct proc *p)
|
||||
if ((sigprop(sig) & SA_IGNORE) != 0)
|
||||
sigqueue_delete_proc(p, sig);
|
||||
}
|
||||
|
||||
/*
|
||||
* As CloudABI processes cannot modify signal handlers, fully
|
||||
* reset all signals to their default behavior. Do ignore
|
||||
* SIGPIPE, as it would otherwise be impossible to recover from
|
||||
* writes to broken pipes and sockets.
|
||||
*/
|
||||
if (SV_PROC_ABI(p) == SV_ABI_CLOUDABI) {
|
||||
osigignore = ps->ps_sigignore;
|
||||
while (SIGNOTEMPTY(osigignore)) {
|
||||
sig = sig_ffs(&osigignore);
|
||||
SIGDELSET(osigignore, sig);
|
||||
if (sig != SIGPIPE)
|
||||
sigdflt(ps, sig);
|
||||
}
|
||||
SIGADDSET(ps->ps_sigignore, SIGPIPE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset stack state to the user stack.
|
||||
* Clear set of signals caught on the signal stack.
|
||||
|
Loading…
Reference in New Issue
Block a user