vfork(2) SDK R4.11 vfork(2)
NAME
vfork - spawn new process in a virtual memory efficient way
SYNOPSIS
#include <sys/types.h>
pidt vfork ()
DESCRIPTION
Vfork creates a new process in the same way that fork(2) does except
that the new process (the child) shares the address space of the
parent rather than being given his own address space that is a copy
of the parent's. The vfork call does not return in the parent
process until the child does an exec, an exit, or terminates
abnormally. The vfork call does return in the child process,
whereupon it is expected the child will call exec very soon.
Vfork can normally be used just like fork, except after the vfork
call the child must be careful about modifying the user address space
since the changes will be reflected in the parent when he continues.
It does not work, for example, for the child process to return from
the procedure which called vfork because the parent would return to a
no-longer-existent stack frame.
If the following process address space attributes are changed by the
child, those changes will be visible to the parent:
· The shared memory segments (see shmat and shmdt).
· The unshared data segment as a result of changing the break
value (see brk and sbrk).
· The text or data segment locks (see plock).
Vfork cannot be used by multi-threaded processes since it is possible
for other threads in the parent process that are not involved in the
vfork call to alter the process address space. This could cause
undesirable affects to the child process that is expecting the parent
to be stopped.
ACCESS CONTROL
No access checking is performed.
RETURN VALUE
Upon successful completion, vfork returns a value of 0 to the child
process and (later) returns the process ID of the child process to
the parent process. Otherwise a value of -1 is returned to the
parent process, no child process is created, and errno is set to
indicate the error.
DIAGNOSTICS
Vfork will fail and no child process will be created if one or more
of the following are true:
EAGAIN The system-imposed limit on the total number of processes
under execution would be exceeded.
EAGAIN The calling process is not, on a generic DG/UX system, a
superuser, or, does not, on a system with DG/UX information
security, have appropriate privilege, and there already
exists cf_pm_max_processes_per_real_user_id processes with
the same real user id as the calling process. For systems
with DG/UX information security, appropriate privilege is
defined as having one or more specific capabilities enabled
in the effective capability set of the calling process.
See capdefaults(5) for the default capability for this
system call.
On a generic DG/UX system, appropriate privilege means that the
process has an effective UID of root.
ENOMEM The process requires more space than the system is able to
supply.
EINVAL The process is multi-threaded.
SEE ALSO
exec(2), fork(2), nice(2), plock(2), ptrace(2), semop(2), signal(2),
sigset(2), times(2), ulimit(2), umask(2), wait(2),
appropriateprivilege(5), capdefaults(5).
NOTES
To avoid a possible deadlock, child processes in the middle of a
vfork are never sent SIGTTOU or SIGTTIN signals; rather, output or
ioctls are allowed and input attempts result in an end-of-file
indication.
STANDARDS
When using m88kbcs as the Software Development Environment target,
the vfork function will be an incomplete emulation of Berkeley
semantics. This emulation does not support the virtual fork
capability but is simply a call to fork.
Licensed material--property of copyright holder(s)