HP-UX Reference (11i v2 04/09) - 2 System Calls (vol 5)
f
fork(2) fork(2)
If a parent and child process both have a file opened and the parent or child closes the file, the file is still
open for the other process.
RETURN VALUE
Upon successful completion,
fork() returns a value of
0 to the child process and 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.
The parent and child processes resume execution immediately after the
fork() call; they are dis-
tinguished by the value returned by
fork.
ERRORS
If
fork() fails, errno is set to one of the following values.
[EAGAIN] The system-imposed limit on the total number of processes under execution would
be exceeded.
[EAGAIN] The system-imposed limit on the total number of processes under execution by a
single user would be exceeded.
[ENOMEM] There is insufficient swap space and/or physical memory available in which to
create the new process.
WARNINGS
Standard I/O streams (see stdio (3S)) are duplicated in the child. Therefore, if
fork is called after a
buffered I/O operation without first closing or flushing the associated standard I/O stream (see fclose (3S)),
the buffered input or output might be duplicated.
DEPENDENCIES
HP Process Resource Manager
If the optional HP Process Resource Manager (PRM) software is installed and configured, the child pro-
cess inherits the parent’s process resource group ID. See prmconfig(1) for a description of how to
configure HP PRM, and prmconf(4) for the definition of process resource group.
AUTHOR
fork() was developed by AT&T, the University of California, Berkeley, and HP.
SEE ALSO
acct(2), chroot(2), exec(2), exit(2), fcntl(2), getgroups(2), lockf(2), nice(2), plock(2), profil(2),
pthread_atfork(3T), ptrace(2), rtprio(2), semop(2), setpgrp(2), setuid(2), shmop(2), times(2), ulimit(2),
umask(2), vfork(2), wait(2), fclose(3S), stdio(3S), acct(4), signal(5).
HP Process Resource Manager: prmconfig(1), prmconf(4) in HP Process Resource Manager User’s Guide.
STANDARDS CONFORMANCE
fork(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
HP-UX 11i Version 2: September 2004 − 2 − Hewlett-Packard Company Section 2−−73