From owner-svn-src-head@freebsd.org Wed Aug 12 11:30:32 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B82EB99F607; Wed, 12 Aug 2015 11:30:32 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A93B0F14; Wed, 12 Aug 2015 11:30:32 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7CBUWBi095477; Wed, 12 Aug 2015 11:30:32 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7CBUW8C095476; Wed, 12 Aug 2015 11:30:32 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201508121130.t7CBUW8C095476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Wed, 12 Aug 2015 11:30:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286662 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Aug 2015 11:30:32 -0000 Author: ed Date: Wed Aug 12 11:30:31 2015 New Revision: 286662 URL: https://svnweb.freebsd.org/changeset/base/286662 Log: 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 Modified: head/sys/kern/kern_sig.c Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Wed Aug 12 11:07:03 2015 (r286661) +++ head/sys/kern/kern_sig.c Wed Aug 12 11:30:31 2015 (r286662) @@ -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.