aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_sig.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index e39290dd43c9..b57f6b6e5b9d 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -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.