[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#338182: kfreebsd-5: signals for linuxthreads internal operation



Package:  kfreebsd-5  
Severity: wishlist
Tags: patch

Hi,

with attached patch for kernel and clone.c it should be possible leave 
SIGUSR1 and SIGUSR2 free for user code.

Current libc will work with current and new kernel, 
new libc will require new kernel.

Petr

--- clone.c.OLD 2005-11-08 17:25:02.000000000 +0100
+++ clone.c     2005-11-08 17:32:18.000000000 +0100
@@ -64,13 +64,13 @@
 
   if ((flags & CSIGNAL) != 0 && (flags & CSIGNAL) != SIGCHLD)
     {
-      /* This implementation of clone() supports only the SIGUSR1 signal.  */
-      if ((flags & CSIGNAL) != SIGUSR1)
+      /* This implementation of clone() supports only the 128 signals.  */
+      if ((flags & CSIGNAL) & RFTHPNMASK)
        {
          __set_errno (EINVAL);
          return -1;
        }
-      rfork_flags |= RFLINUXTHPN;
+      rfork_flags |= (RFLINUXTHPN | ((flags & CSIGNAL) <<  RFTHPNSHIFT));
     }
 
   if (flags & CLONE_VM)


diff -ur sys.old/kern/kern_fork.c sys/kern/kern_fork.c
--- sys.old/kern/kern_fork.c	2005-04-27 13:32:23.000000000 +0200
+++ sys/kern/kern_fork.c	2005-11-08 17:17:43.000000000 +0100
@@ -502,7 +502,11 @@
 		p2->p_sigacts = newsigacts;
 	}
 	if (flags & RFLINUXTHPN) 
-	        p2->p_sigparent = SIGUSR1;
+	{
+		int sig;
+		sig = RFTHPNSIGNUM(flags);
+	        p2->p_sigparent = sig ? sig : SIGUSR1;
+	}
 	else
 	        p2->p_sigparent = SIGCHLD;
 
diff -ur sys.old/sys/unistd.h sys/sys/unistd.h
--- sys.old/sys/unistd.h	2005-02-01 00:26:57.000000000 +0100
+++ sys/sys/unistd.h	2005-11-08 17:14:12.000000000 +0100
@@ -173,6 +173,10 @@
 #define	RFHIGHPID	(1<<18)	/* use a pid higher then 10 (idleproc) */
 #define	RFPPWAIT	(1<<31)	/* parent sleeps until child exits (vfork) */
 #define	RFKERNELONLY	(RFSTOPPED | RFHIGHPID | RFPPWAIT)
+#define RFTHPNSHIFT	24	/* reserve bits 24-30 */
+#define RFTHPNMASK	0x7F    /* for compatibility with linuxthreads/clone()   */
+				/* allow to specify  "clone exit parent notification" signal */
+#define RFTHPNSIGNUM(flags)	(((flags) >> RFTHPNSHIFT) & RFTHPNMASK)
 
 #endif /* __BSD_VISIBLE */
 

Reply to: