[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [autoconf] AmigaOS fork()

From: Tim Van Holder
Subject: Re: [autoconf] AmigaOS fork()
Date: Tue, 12 Jun 2001 18:44:00 +0200

> Actually, the original definition of 'vfork' said that one should not
> rely on this behavior.  And in the latest POSIX draft (POSIX
> 1003.1-200x draft 5) the rationale states simply "On some
> implementations, vfork() is equivalent to fork()."

Actually, the latest draft is nr 6 (April 2001).  It now states:

Conforming applications are recommended not to depend on vfork(), but to use
fork() instead.
The vfork() function may be withdrawn in a future version.
On some implementations, vfork() is equivalent to fork().
The vfork() function differs from fork() only in that the child process can
share code and data
with the calling process (parent process). This speeds cloning activity
significantly at a risk to
the integrity of the parent process if vfork() is misused.
The use of vfork() for any purpose except as a prelude to an immediate call
to a function from
the exec family, or to _exit(), is not advised.
The vfork() function can be used to create new processes without fully
copying the address
space of the old process. If a forked process is simply going to call exec,
the data space copied
from the parent to the child by fork() is not used. This is particularly
inefficient in a paged
environment, making vfork() particularly useful. Depending upon the size of
the parent’s data
space, vfork() can give a significant performance improvement over fork().
The vfork() function can normally be used just like fork(). It does not
work, however, to return
while running in the child’s context from the caller of vfork() since the
eventual return from
vfork() would then return to a no longer existent stack frame. Care should
be taken, also, to call
_exit() rather than exit() if exec cannot be used, since exit() flushes and
closes standard I/O
channels, thereby damaging the parent process’ standard I/O data structures.
(Even with fork(),
it is wrong to call exit(), since buffered data would then be flushed
If signal handlers are invoked in the child process after vfork(), they must
follow the same rules
as other code in the child process.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]