Date: Wed, 25 Oct 1995 14:02:57 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: rminnich@Sarnoff.COM (Ron G. Minnich) Cc: deraadt@theos.com, hackers@FreeBSD.org Subject: Re: anatomy of rfork, part 2: fork code Message-ID: <199510252102.OAA19472@phaeton.artisoft.com> In-Reply-To: <Pine.SUN.3.91.951025145433.28796A-100000@terra> from "Ron G. Minnich" at Oct 25, 95 03:02:53 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> /* bump references to the text vnode (for procfs) */
> p2->p_textvp = p1->p_textvp;
> if (p2->p_textvp)
> VREF(p2->p_textvp);
>
> /* BEGIN CHANGED CODE FOR RFORK FOR DUPFD () */
> if (dupfd)
> p2->p_fd = fdcopy(p1);
> else
> {
> /* make this a function at some point */
> /* danger!!! no locks!!! */
> p2->p_fd = p1->p_fd;
> p2->p_fd->fd_refcnt++;
> }
One presumes exit(2) knows how to clean this up?
I implemented fd table sharing in UnixWare 2.0 using something similar
to the following in the user process:
/*
* Set up proc so normal for will cause FD's to be
* inherited.
*/
/* get our name in procfs*/
sprintf( pnamebuf, "/proc/%d", getpid());
/* open ourselves*/
if( ( procfd = open( pnamebuf, O_RDWR)) == -1) {
perror( "open: context sharing");
exit( 1);
}
/* unset the defualt "copy fd table on fork" flag*/
if( ioctl( procfd, PFS_INHERITFDTAB, 1)) {
perror( "ioctl: context sharing");
exit( 1);
}
/* done*/
close( procfd);
Which does the same thing without requiring the introduction of an
additional system call interface or fork abstraction.
Terry Lambert
terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510252102.OAA19472>
