Add FORK_CLEANFILES flag to fork1(), which makes the new process start out
with a clean descriptor set (ie. not copied or shared from parent). for rfork()
This commit is contained in:
parent
4b843a85e4
commit
2bc5807797
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_fork.c,v 1.90 2002/07/11 10:37:26 pooka Exp $ */
|
/* $NetBSD: kern_fork.c,v 1.91 2002/08/06 13:58:08 pooka Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
|
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.90 2002/07/11 10:37:26 pooka Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.91 2002/08/06 13:58:08 pooka Exp $");
|
||||||
|
|
||||||
#include "opt_ktrace.h"
|
#include "opt_ktrace.h"
|
||||||
#include "opt_systrace.h"
|
#include "opt_systrace.h"
|
||||||
|
@ -381,6 +381,8 @@ fork1(struct proc *p1, int flags, int exitsig, void *stack, size_t stacksize,
|
||||||
|
|
||||||
if (flags & FORK_SHAREFILES)
|
if (flags & FORK_SHAREFILES)
|
||||||
fdshare(p1, p2);
|
fdshare(p1, p2);
|
||||||
|
else if (flags & FORK_CLEANFILES)
|
||||||
|
p2->p_fd = fdinit(p1);
|
||||||
else
|
else
|
||||||
p2->p_fd = fdcopy(p1);
|
p2->p_fd = fdcopy(p1);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: proc.h,v 1.142 2002/07/25 20:04:04 jdolecek Exp $ */
|
/* $NetBSD: proc.h,v 1.143 2002/08/06 13:58:09 pooka Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1986, 1989, 1991, 1993
|
* Copyright (c) 1986, 1989, 1991, 1993
|
||||||
|
@ -367,6 +367,7 @@ do { \
|
||||||
#define FORK_SHAREFILES 0x08 /* Share file descriptors */
|
#define FORK_SHAREFILES 0x08 /* Share file descriptors */
|
||||||
#define FORK_SHARESIGS 0x10 /* Share signal actions */
|
#define FORK_SHARESIGS 0x10 /* Share signal actions */
|
||||||
#define FORK_NOWAIT 0x20 /* Make init the parent of the child */
|
#define FORK_NOWAIT 0x20 /* Make init the parent of the child */
|
||||||
|
#define FORK_CLEANFILES 0x40 /* Start with a clean descriptor set */
|
||||||
|
|
||||||
#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
|
#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
|
||||||
extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
|
extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
|
||||||
|
|
Loading…
Reference in New Issue