Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jul 2011 11:16:28 +0200 (CEST)
From:      Petr Salinger <Petr.Salinger@seznam.cz>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        freebsd-hackers@freebsd.org, Robert Millan <rmh@debian.org>, current@freebsd.org
Subject:   Re: [PATCH] Improve LinuxThreads compatibility in rfork()
Message-ID:  <alpine.LRH.2.02.1107121108300.10573@sci.felk.cvut.cz>
In-Reply-To: <20110711180246.GA43872@deviant.kiev.zoral.com.ua>
References:  <20110711133342.GT43872@deviant.kiev.zoral.com.ua> <alpine.LRH.2.02.1107111556000.7134@sci.felk.cvut.cz> <20110711142232.GU43872@deviant.kiev.zoral.com.ua> <alpine.LRH.2.02.1107111641340.7134@sci.felk.cvut.cz> <20110711150614.GV43872@deviant.kiev.zoral.com.ua> <alpine.LRH.2.02.1107111718440.7134@sci.felk.cvut.cz> <20110711154102.GW43872@deviant.kiev.zoral.com.ua> <alpine.LRH.2.02.1107111805350.7134@sci.felk.cvut.cz> <20110711172408.GX43872@deviant.kiev.zoral.com.ua> <alpine.LRH.2.02.1107111944550.7134@sci.felk.cvut.cz> <20110711180246.GA43872@deviant.kiev.zoral.com.ua>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
>> Seems this interface be acceptable ?
>
> Looks good to me.

The proposed code changes are in the attached patch.

Proposed wording of addition into RFORK(2):

DESCRIPTION:

RFTSIGZMB  	If set, the kernel will return selected signal number instead
                 of SIGCHILD upon thread exit for the child.
                 The selected signal number have to be encoded into flags
                 by ORing RFTSIGFLAGS(signum).

ERRORS:

EINVAL          An invalid signal was specified.


Petr
[-- Attachment #2 --]
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -476,7 +476,10 @@
 		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;
@@ -723,6 +726,9 @@
 	if ((flags & (RFFDG|RFCFDG)) == (RFFDG|RFCFDG))
 		return (EINVAL);
 
+	if ((flags & RFTSIGZMB) && (RFTSIGNUM(flags) > _SIG_MAXSIG))
+		return (EINVAL);
+
 	p1 = td->td_proc;
 
 	/*
--- a/sys/sys/unistd.h
+++ b/sys/sys/unistd.h
@@ -180,6 +180,11 @@
 #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)
 
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.LRH.2.02.1107121108300.10573>