svn commit: r224211 - in stable/8/sys: kern sys
Konstantin Belousov
kib at FreeBSD.org
Tue Jul 19 10:41:26 UTC 2011
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 */
More information about the svn-src-stable-8
mailing list