Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!uw-june!uw-entropy!quick!srg From: srg@quick.COM (Spencer Garrett) Newsgroups: comp.arch,comp.unix.wizards,comp.os.minix Subject: Re: UNIX fork Message-ID: <125@quick.COM> Date: Sun, 27-Sep-87 17:13:50 EDT Article-I.D.: quick.125 Posted: Sun Sep 27 17:13:50 1987 Date-Received: Mon, 28-Sep-87 03:06:52 EDT References: <1665@ncr-sd.SanDiego.NCR.COM> <8381@utzoo.UUCP> <797@Pescadero.ARPA> <840@usfvax2.UUCP> Organization: Quicksilver Engineering, Seattle Lines: 18 Xref: mnetor comp.arch:2393 comp.unix.wizards:4545 comp.os.minix:1733 In article <7672@felix.UUCP>, preston@felix.UUCP (Preston Bannister) writes: } In article <838@usfvax2.UUCP> chips@usfvax2.UUCP (Chip Salzenberg) writes: } } >There is one thing about UNIX fork()-exec() that you've overlooked -- } >after the fork(), the child process can set up the environment of the } >soon-to-be-exec'ed process by modifying its own environment. } >(Can you say `pipes, I/O redirection and current directory'? } >I knew you could.) } } What I should have said :-) was that the } code executed between the fork() and exec() call typically does not } need the full semantics of fork(). Indeed it does not. That's why Berkeley has vfork(). A vfork call "borrows" the parent's memory instead of copying it. The parent is kept in suspended animation while the child modifies the new environment. When the child exec's (or exit's) the memory is given back to the parent instead of being freed.