From owner-svn-src-stable-8@FreeBSD.ORG Tue Jul 19 10:41:26 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D49BA106566B; Tue, 19 Jul 2011 10:41:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AB05B8FC0A; Tue, 19 Jul 2011 10:41:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6JAfQwa066938; Tue, 19 Jul 2011 10:41:26 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6JAfQEs066935; Tue, 19 Jul 2011 10:41:26 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107191041.p6JAfQEs066935@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 19 Jul 2011 10:41:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224211 - in stable/8/sys: kern sys X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2011 10:41:26 -0000 Author: kib Date: Tue Jul 19 10:41:26 2011 New Revision: 224211 URL: http://svn.freebsd.org/changeset/base/224211 Log: MFC r223966: Implement an RFTSIGZMB flag to rfork(2) to specify a signal that is delivered to parent when the child exists. Modified: stable/8/sys/kern/kern_fork.c stable/8/sys/sys/unistd.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_fork.c ============================================================================== --- stable/8/sys/kern/kern_fork.c Tue Jul 19 09:27:37 2011 (r224210) +++ stable/8/sys/kern/kern_fork.c Tue Jul 19 10:41:26 2011 (r224211) @@ -218,10 +218,22 @@ fork1(td, flags, pages, procp) vm_ooffset_t mem_charged; int error; + /* Check for the undefined or unimplemented flags. */ + if ((flags & ~(RFFLAGS | RFTSIGFLAGS(RFTSIGMASK))) != 0) + return (EINVAL); + + /* Signal value requires RFTSIGZMB. */ + if ((flags & RFTSIGFLAGS(RFTSIGMASK)) != 0 && (flags & RFTSIGZMB) == 0) + return (EINVAL); + /* Can't copy and clear. */ if ((flags & (RFFDG|RFCFDG)) == (RFFDG|RFCFDG)) return (EINVAL); + /* Check the validity of the signal number. */ + if ((flags & RFTSIGZMB) != 0 && (u_int)RFTSIGNUM(flags) > _SIG_MAXSIG) + return (EINVAL); + p2_held = 0; p1 = td->td_proc; @@ -567,7 +579,10 @@ again: sigacts_copy(newsigacts, p1->p_sigacts); p2->p_sigacts = newsigacts; } - if (flags & RFLINUXTHPN) + + if (flags & RFTSIGZMB) + p2->p_sigparent = RFTSIGNUM(flags); + else if (flags & RFLINUXTHPN) p2->p_sigparent = SIGUSR1; else p2->p_sigparent = SIGCHLD; Modified: stable/8/sys/sys/unistd.h ============================================================================== --- stable/8/sys/sys/unistd.h Tue Jul 19 09:27:37 2011 (r224210) +++ stable/8/sys/sys/unistd.h Tue Jul 19 10:41:26 2011 (r224211) @@ -180,8 +180,16 @@ #define RFLINUXTHPN (1<<16) /* do linux clone exit parent notification */ #define RFSTOPPED (1<<17) /* leave child in a stopped state */ #define RFHIGHPID (1<<18) /* use a pid higher than 10 (idleproc) */ +#define RFTSIGZMB (1<<19) /* select signal for exit parent notification */ +#define RFTSIGSHIFT 20 /* selected signal number is in bits 20-27 */ +#define RFTSIGMASK 0xFF +#define RFTSIGNUM(flags) (((flags) >> RFTSIGSHIFT) & RFTSIGMASK) +#define RFTSIGFLAGS(signum) ((signum) << RFTSIGSHIFT) #define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */ #define RFKERNELONLY (RFSTOPPED | RFHIGHPID | RFPPWAIT) +#define RFFLAGS (RFFDG | RFPROC | RFMEM | RFNOWAIT | RFCFDG | \ + RFTHREAD | RFSIGSHARE | RFLINUXTHPN | RFSTOPPED | RFHIGHPID | RFTSIGZMB | \ + RFPPWAIT) #endif /* __BSD_VISIBLE */