Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Nov 1998 22:15:53 -0500 (EST)
From:      Brian Feldman <green@unixhelp.org>
To:        current@FreeBSD.ORG
Subject:   RFSIGSHARE: forgot patch ;)
Message-ID:  <Pine.BSF.4.05.9811042214220.25785-100000@janus.syracuse.net>

next in thread | raw e-mail | index | archive | help
Woops, sorry, here is the patchset :)
--- ./i386/linux/linux_dummy.c.orig	Thu Nov  6 14:28:52 1997
+++ ./i386/linux/linux_dummy.c	Wed Nov  4 20:48:40 1998
@@ -212,13 +212,6 @@
 }
 
 int
-linux_clone(struct proc *p, struct linux_clone_args *args)
-{
-    printf("Linux-emul(%d): clone() not supported\n", p->p_pid);
-    return ENOSYS;
-}
-
-int
 linux_uname(struct proc *p, struct linux_uname_args *args)
 {
     printf("Linux-emul(%d): uname() not supported\n", p->p_pid);
--- ./i386/linux/linux_misc.c.orig	Mon Oct  5 08:40:42 1998
+++ ./i386/linux/linux_misc.c	Wed Nov  4 21:13:31 1998
@@ -41,6 +41,7 @@
 #include <sys/resourcevar.h>
 #include <sys/stat.h>
 #include <sys/sysctl.h>
+#include <sys/unistd.h>
 #include <sys/vnode.h>
 #include <sys/wait.h>
 #include <sys/time.h>
@@ -557,6 +558,56 @@
 	return error;
     if (p->p_retval[1] == 1)
 	p->p_retval[0] = 0;
+    return 0;
+}
+
+#define CLONE_VM	0x100
+#define CLONE_FS	0x200
+#define CLONE_FILES	0x400
+#define CLONE_SIGHAND	0x800
+#define CLONE_PID	0x1000
+
+int
+linux_clone(struct proc *p, struct linux_clone_args *args)
+{
+    int error, ff = RFPROC, top;
+    struct proc *p2;
+
+#ifdef SMP
+    printf("linux_clone(%d): does not work with SMP\n", p->p_pid);
+    return (EOPNOTSUPP);
+#endif
+#ifdef DEBUG_CLONE
+    printf("linux_clone(%#x, %#x)\n", ((int *)args)[0],
+	((int *)args)[1]);
+    if (args->flags & CLONE_PID)
+	printf("linux_clone: CLONE_PID not yet supported\n");
+    if (args->flags & CLONE_FS)
+	printf("linux_clone: CLONE_FS not yet supported\n");
+#endif
+    if (args->flags & CLONE_VM)
+	ff |= RFMEM;
+    if (args->flags & CLONE_SIGHAND)
+	ff |= RFSIGSHARE;
+    ff |= (args->flags & CLONE_FILES) ? RFFDG : RFCFDG;
+    if (error = fork1(p, ff))
+	return error;
+    p2 = pfind(p->p_retval[0]);
+    if (p2 == 0)
+	return ESRCH;
+    if (args->stack) {
+	copyin(args->stack, &top, 4);
+	p2->p_md.md_regs->tf_esp = (int)args->stack;
+	p2->p_md.md_regs->tf_eip = top;
+     }
+     if (args->flags & CLONE_SIGHAND)
+	p2->p_sigacts = p->p_sigacts;
+#ifdef DEBUG_CLONE
+    copyin(args->stack + 4, &top, 4);
+    printf("linux_clone: pids %d, %d; child eip=%#x, esp=%#x,
*esp=%#x\n",
+	p->p_pid, p2->p_pid, p2->p_md.md_regs->tf_eip,
p2->p_md.md_regs->tf_esp,
+	top);
+#endif
     return 0;
 }
 
--- ./i386/linux/linux_proto.h.orig	Fri Jul 10 18:30:04 1998
+++ ./i386/linux/linux_proto.h	Wed Nov  4 20:48:40 1998
@@ -2,7 +2,7 @@
  * System call prototypes.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	Id: syscalls.master,v 1.11 1998/06/09 03:28:14 bde
Exp 
+ * created from	Id: syscalls.master,v 1.12 1998/07/10 22:30:08 jkh
Exp 
  */
 
 #ifndef _LINUX_SYSPROTO_H_
@@ -301,7 +301,8 @@
 	struct linux_sigcontext *	scp;	char scp_[PAD_(struct
linux_sigcontext *)];
 };
 struct	linux_clone_args {
-	register_t dummy;
+	int	flags;	char flags_[PAD_(int)];
+	void *	stack;	char stack_[PAD_(void *)];
 };
 struct	linux_newuname_args {
 	struct linux_newuname_t *	buf;	char buf_[PAD_(struct
linux_newuname_t *)];
--- ./i386/linux/linux_syscall.h.orig	Fri Jul 10 18:30:06 1998
+++ ./i386/linux/linux_syscall.h	Wed Nov  4 20:48:40 1998
@@ -2,7 +2,7 @@
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	Id: syscalls.master,v 1.11 1998/06/09 03:28:14 bde
Exp 
+ * created from	Id: syscalls.master,v 1.12 1998/07/10 22:30:08 jkh
Exp 
  */
 
 #define	LINUX_SYS_linux_setup	0
--- ./i386/linux/linux_sysent.c.orig	Fri Jul 10 18:30:07 1998
+++ ./i386/linux/linux_sysent.c	Wed Nov  4 20:48:40 1998
@@ -2,7 +2,7 @@
  * System call switch table.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	Id: syscalls.master,v 1.11 1998/06/09 03:28:14 bde
Exp 
+ * created from	Id: syscalls.master,v 1.12 1998/07/10 22:30:08 jkh
Exp 
  */
 
 #include "opt_compat.h"
@@ -134,7 +134,7 @@
 	{ 5, (sy_call_t *)linux_ipc },			/* 117 = linux_ipc
*/
 	{ 1, (sy_call_t *)fsync },			/* 118 = fsync */
 	{ 1, (sy_call_t *)linux_sigreturn },		/* 119 =
linux_sigreturn */
-	{ 0, (sy_call_t *)linux_clone },		/* 120 =
linux_clone */
+	{ 2, (sy_call_t *)linux_clone },		/* 120 =
linux_clone */
 	{ 2, (sy_call_t *)setdomainname },		/* 121 =
setdomainname */
 	{ 1, (sy_call_t *)linux_newuname },		/* 122 =
linux_newuname */
 	{ 3, (sy_call_t *)linux_modify_ldt },		/* 123 =
linux_modify_ldt */
--- ./i386/linux/syscalls.master.orig	Fri Jul 10 18:30:08 1998
+++ ./i386/linux/syscalls.master	Wed Nov  4 20:48:40 1998
@@ -171,7 +171,7 @@
 			    caddr_t ptr); }
 118	NOPROTO	LINUX	{ int fsync(int fd); }
 119	STD	LINUX	{ int linux_sigreturn(struct linux_sigcontext
*scp); }
-120	STD	LINUX	{ int linux_clone(void); }
+120	STD	LINUX	{ int linux_clone(int flags, void *stack); }
 121	NOPROTO	LINUX	{ int setdomainname(char *name, \
 			    int len); }
 122	STD	LINUX	{ int linux_newuname(struct linux_newuname_t
*buf); }
--- ./kern/kern_fork.c.orig	Wed Nov  4 20:33:11 1998
+++ ./kern/kern_fork.c	Wed Nov  4 20:44:29 1998
@@ -151,6 +151,10 @@
 		    p1->p_pid);
 		return (EOPNOTSUPP);
 	}
+	if (flags & RFSIGSHARE) {
+		printf("shared signal space attemped: pid: %d\n",
p1->p_pid);
+		return (EOPNOTSUPP);
+	}
 #endif
 
 	/*
@@ -320,6 +324,16 @@
 	bcopy(p1->p_cred, p2->p_cred, sizeof(*p2->p_cred));
 	p2->p_cred->p_refcnt = 1;
 	crhold(p1->p_ucred);
+
+	if (flags & RFSIGSHARE) {
+		p2->p_sig->p_refcnt++;
+	} else {
+		p2->p_sig = malloc(sizeof(struct procsig), M_TEMP,
M_WAITOK);
+		p2->p_sig->p_refcnt = 1;
+		p2->p_sigmask = p1->p_sigmask;
+		p2->p_sigignore = p1->p_sigignore;
+		p2->p_sigcatch = p1->p_sigcatch;
+	}
 
 	/* bump references to the text vnode (for procfs) */
 	p2->p_textvp = p1->p_textvp;
--- ./kern/kern_exit.c.orig	Wed Nov  4 20:45:09 1998
+++ ./kern/kern_exit.c	Wed Nov  4 20:46:50 1998
@@ -333,6 +333,11 @@
 		p->p_limit = NULL;
 	}
 
+	if (--p->p_sig->p_refcnt == 0) {
+		free(p->p_sig, M_TEMP);
+		p->p_sig = NULL;
+	}
+
 	/*
 	 * Finally, call machine-dependent code to release the remaining
 	 * resources including address space, the kernel stack and pcb.
--- ./kern/init_main.c.orig	Wed Nov  4 16:27:04 1998
+++ ./kern/init_main.c	Wed Nov  4 16:41:15 1998
@@ -83,6 +83,7 @@
 static struct pgrp pgrp0;
 struct	proc proc0;
 static struct pcred cred0;
+static struct procsig procsig0;
 static struct filedesc0 filedesc0;
 static struct plimit limit0;
 static struct vmspace vmspace0;
@@ -414,6 +415,11 @@
 	p->p_cred = &cred0;
 	p->p_ucred = crget();
 	p->p_ucred->cr_ngroups = 1;	/* group 0 */
+
+	/* Create procsig. */
+	p->p_sig = &procsig0;
+	p->p_sig->p_refcnt = 2;
+	p->p_sigmask = p->p_sigcatch = p->p_sigignore = 0;
 
 	/* Create the file descriptor table. */
 	fdp = &filedesc0;
--- ./sys/proc.h.orig	Wed Nov  4 20:22:32 1998
+++ ./sys/proc.h	Wed Nov  4 20:30:41 1998
@@ -75,6 +75,13 @@
 	int	pg_jobc;	/* # procs qualifying pgrp for job control
*/
 };
 
+struct	procsig {
+	int	 p_refcnt;
+	sigset_t p_sigmask;	/* Current signal mask. */
+	sigset_t p_sigignore;	/* Signals being ignored. */
+	sigset_t p_sigcatch;	/* Signals being caught by user. */
+};
+
 /*
  * Description of a process.
  *
@@ -165,12 +172,12 @@
 #define	p_endzero	p_startcopy
 
 /* The following fields are all copied upon creation in fork. */
-#define	p_startcopy	p_sigmask
-
-	sigset_t p_sigmask;	/* Current signal mask. */
-	sigset_t p_sigignore;	/* Signals being ignored. */
-	sigset_t p_sigcatch;	/* Signals being caught by user. */
+#define	p_startcopy	p_sig
 
+	struct	procsig *p_sig;
+#define p_sigmask p_sig->p_sigmask
+#define p_sigignore p_sig->p_sigignore
+#define p_sigcatch p_sig->p_sigcatch
 	u_char	p_priority;	/* Process priority. */
 	u_char	p_usrpri;	/* User-priority based on p_cpu and
p_nice. */
 	char	p_nice;		/* Process "nice" value. */
--- ./sys/unistd.h.orig	Wed Nov  4 20:32:28 1998
+++ ./sys/unistd.h	Wed Nov  4 20:33:00 1998
@@ -186,6 +186,7 @@
 #define RFCENVG		(1<<11) /* UNIMPL zero plan9 `env space'
*/
 #define RFCFDG		(1<<12) /* zero fd table */
 #define RFTHREAD	(1<<13)	/* enable kernel thread support */
+#define RFSIGSHARE	(1<<14)	/* share signal masks */
 #define RFPPWAIT	(1<<31) /* parent sleeps until child exits (vfork)
*/
 
 #endif /* !_POSIX_SOURCE */



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9811042214220.25785-100000>