[Info-vax] Looking into C-include files on VMS
MetaEd
metaed at gmail.com
Wed Nov 4 14:23:37 EST 2009
On Nov 4, 2:56 am, glen herrmannsfeldt <g... at ugcs.caltech.edu> wrote:
> As it is rare that you want to share the variables and open files,
> and most common to exec(), vfork() was added.
vfork() was never more than a kludge to get around the the lack of
copy on write pages that originally slowed fork() down. fork() has
been fixed, and vfork() is often just a wrapper around fork().
It is common to fork() and never exec(). In network programming, a
server process will take the next connection request off the queue,
call fork(), and go back to listen for the next request. The child
handles the request from start to finish and then exits. You see this
in web servers, mail servers, name servers, any type of network
service where you listen for connections.
And far more commonly still, you see it in the shell wherever a shell
script has a pipeline operator "|". The shell will create a pipe and
call fork(), one child running the code on the left hand side and
having the pipe as standard output, another child running the code on
the right hand side and having the pipe as standard input. The
children will not call exec() unless one side of the pipeline or the
other is a simple command.
vfork() does not avoid sharing of open files. Children have the open
files of the parent.
vfork() does not avoid sharing of variables. It's the opposite. vfork
() maps the child's data space to the parent's data space, letting the
child modify the parent. fork(), on the other hand, duplicates the
data space and gives the duplicate to the child.
More information about the Info-vax
mailing list