Date: Fri, 6 Nov 1998 21:27:50 -0500 (EST) From: Brian Feldman <green@unixhelp.org> To: current@FreeBSD.ORG Subject: RFSIGSHARE ready? Message-ID: <Pine.BSF.4.05.9811062123460.13093-100000@janus.syracuse.net>
next in thread | raw e-mail | index | archive | help
I suppose it is. LinuxThreads don't work tho... I need %@#!^ testers!
Cheers,
Brian Feldman
--- ./i386/linux/linux_dummy.c.orig Wed Nov 4 18:04:02 1998
+++ ./i386/linux/linux_dummy.c Fri Nov 6 18:20:26 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 Wed Nov 4 18:04:02 1998
+++ ./i386/linux/linux_misc.c Fri Nov 6 19:33:02 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>
@@ -558,6 +559,54 @@
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);
+#else
+ if (args->flags & CLONE_PID)
+ printf("linux_clone(%d): CLONE_PID not yet supported\n",
p->p_pid);
+ if (args->flags & CLONE_FS)
+ printf("linux_clone(%d): CLONE_FS not yet supported\n", p->p_pid);
+ if (args->flags & CLONE_VM)
+ ff |= RFMEM;
+ if (args->flags & CLONE_SIGHAND)
+ ff |= RFSIGSHARE;
+ if (!(args->flags & CLONE_FILES))
+ ff |= RFFDG;
+ 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;
+#endif
}
/* XXX move */
--- ./i386/linux/linux_proto.h.orig Wed Nov 4 18:04:02 1998
+++ ./i386/linux/linux_proto.h Fri Nov 6 18:20:26 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 Wed Nov 4 18:04:02 1998
+++ ./i386/linux/linux_syscall.h Fri Nov 6 18:20:26 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 Wed Nov 4 18:04:02 1998
+++ ./i386/linux/linux_sysent.c Fri Nov 6 18:20:26 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 Wed Nov 4 18:04:02 1998
+++ ./i386/linux/syscalls.master Fri Nov 6 18:20:26 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 18:04:03 1998
+++ ./kern/kern_fork.c Fri Nov 6 19:06:57 1998
@@ -321,6 +321,17 @@
p2->p_cred->p_refcnt = 1;
crhold(p1->p_ucred);
+ if (flags & RFSIGSHARE) {
+ p2->p_sig->ps_refcnt++;
+ } else {
+ p2->p_sig = malloc(sizeof(struct procsig), M_TEMP,
M_WAITOK);
+ p2->p_sig->ps_refcnt = 1;
+ bcopy(&p1->p_sig->ps_begincopy, &p2->p_sig->ps_begincopy,
+ (unsigned)&p1->p_sig->ps_endcopy -
+ (unsigned)&p1->p_sig->ps_begincopy);
+ p2->p_sigacts = &p2->p_sig->ps_sigacts;
+ }
+
/* bump references to the text vnode (for procfs) */
p2->p_textvp = p1->p_textvp;
if (p2->p_textvp)
--- ./kern/kern_exit.c.orig Wed Nov 4 18:04:03 1998
+++ ./kern/kern_exit.c Fri Nov 6 19:01:06 1998
@@ -333,6 +333,9 @@
p->p_limit = NULL;
}
+ if (--p->p_sig->ps_refcnt == 0)
+ free(p->p_sig, M_TEMP);
+
/*
* 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 18:04:03 1998
+++ ./kern/init_main.c Fri Nov 6 19:00:10 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;
@@ -415,6 +416,10 @@
p->p_ucred = crget();
p->p_ucred->cr_ngroups = 1; /* group 0 */
+ /* Create procsig. */
+ p->p_sig = &procsig0;
+ p->p_sig->ps_refcnt = 2;
+
/* Create the file descriptor table. */
fdp = &filedesc0;
p->p_fd = &fdp->fd_fd;
@@ -461,11 +466,12 @@
#endif
/*
- * We continue to place resource usage info and signal
- * actions in the user struct so they're pageable.
+ * We continue to place resource usage info in the user struct so
+ * it's pageable.
*/
p->p_stats = &p->p_addr->u_stats;
- p->p_sigacts = &p->p_addr->u_sigacts;
+
+ p->p_sigacts = &p->p_sig->ps_sigacts;
/*
* Charge root for one process.
--- ./sys/proc.h.orig Wed Nov 4 18:04:03 1998
+++ ./sys/proc.h Fri Nov 6 18:58:45 1998
@@ -47,6 +47,7 @@
#include <sys/rtprio.h> /* For struct rtprio. */
#include <sys/select.h> /* For struct selinfo. */
#include <sys/signal.h>
+#include <sys/signalvar.h>
#ifndef KERNEL
#include <sys/time.h> /* For structs itimerval, timeval.
*/
#endif
@@ -75,6 +76,16 @@
int pg_jobc; /* # procs qualifying pgrp for job control
*/
};
+struct procsig {
+#define ps_begincopy ps_sigmask
+ sigset_t ps_sigmask; /* Current signal mask. */
+ sigset_t ps_sigignore; /* Signals being ignored. */
+ sigset_t ps_sigcatch; /* Signals being caught by user. */
+ struct sigacts ps_sigacts;
+#define ps_endcopy ps_refcnt
+ int ps_refcnt;
+};
+
/*
* Description of a process.
*
@@ -165,12 +176,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->ps_sigmask
+#define p_sigignore p_sig->ps_sigignore
+#define p_sigcatch p_sig->ps_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 18:04:03 1998
+++ ./sys/unistd.h Fri Nov 6 18:20:27 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 */
--- ./sys/user.h.orig Fri Nov 6 18:32:09 1998
+++ ./sys/user.h Fri Nov 6 18:32:23 1998
@@ -102,7 +102,6 @@
struct user {
struct pcb u_pcb;
- struct sigacts u_sigacts; /* p_sigacts points here (use it!)
*/
struct pstats u_stats; /* p_stats points here (use it!)
*/
/*
--- ./vm/vm_glue.c.orig Fri Nov 6 18:20:41 1998
+++ ./vm/vm_glue.c Fri Nov 6 18:56:12 1998
@@ -235,8 +235,6 @@
* p_stats; zero the rest of p_stats (statistics).
*/
p2->p_stats = &up->u_stats;
- p2->p_sigacts = &up->u_sigacts;
- up->u_sigacts = *p1->p_sigacts;
bzero(&up->u_stats.pstat_startzero,
(unsigned) ((caddr_t) &up->u_stats.pstat_endzero -
(caddr_t) &up->u_stats.pstat_startzero));
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.9811062123460.13093-100000>
