Professional Documents
Culture Documents
Procesos Man
Procesos Man
Procesos Man
NAME
fork − create a child process
SYNOPSIS
#include <unistd.h>
pid_t fork(void);
DESCRIPTION
fork creates a child process that differs from the parent
process only in its PID and PPID, and in the fact that
resource utilizations are set to 0. File locks and pend-
ing signals are not inherited.
RETURN VALUE
On success, the PID of the child process is returned in
the parent’s thread of execution, and a 0 is returned in
the child’s thread of execution. On failure, a −1 will be
returned in the parent’s context, no child process will be
created, and errno will be set appropriately.
ERRORS
EAGAIN fork cannot allocate sufficient memory to copy the
parent’s page tables and allocate a task structure
for the child.
CONFORMING TO
The fork call conforms to SVr4, SVID, POSIX, X/OPEN, BSD
4.3.
SEE ALSO
clone(2), execve(2), vfork(2), wait(2)
NAME
exit − cause normal program termination
SYNOPSIS
#include <stdlib.h>
DESCRIPTION
The exit() function causes normal program termination and
the value of status is returned to the parent. All func-
tions registered with atexit() and on_exit() are called in
the reverse order of their registration, and all open
streams are flushed and closed.
RETURN VALUE
The exit() function does not return.
CONFORMING TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
_exit(2), atexit(3), on_exit(3)
NAME
wait, waitpid − wait for process termination
SYNOPSIS
#include <sys/types.h>
#include <sys/wait.h>
DESCRIPTION
The wait function suspends execution of the current pro-
cess until a child has exited, or until a signal is deliv-
ered whose action is to terminate the current process or
to call a signal handling function. If a child has
already exited by the time of the call (a so−called "zom-
bie" process), the function returns immediately. Any sys-
tem resources used by the child are freed.
WNOHANG
which means to return immediately if no child has
exited.
WUNTRACED
which means to also return for children which are
stopped, and whose status has not been reported.
WIFEXITED(status)
is non−zero if the child exited normally.
WEXITSTATUS(status)
evaluates to the least significant eight bits of
the return code of the child which terminated,
which may have been set as the argument to a call
to exit() or as the argument for a return statement
in the main program. This macro can only be evalu-
ated if WIFEXITED returned non−zero.
WIFSIGNALED(status)
returns true if the child process exited because of
a signal which was not caught.
WTERMSIG(status)
returns the number of the signal that caused the
child process to terminate. This macro can only be
evaluated if WIFSIGNALED returned non−zero.
WIFSTOPPED(status)
returns true if the child process which caused the
return is currently stopped; this is only possible
if the call was done using WUNTRACED.
WSTOPSIG(status)
returns the number of the signal which caused the
child to stop. This macro can only be evaluated if
WIFSTOPPED returned non−zero.
RETURN VALUE
The process ID of the child which exited, −1 on error or
zero if WNOHANG was used and no child was available (in
which case, errno is set to an appropriate value).
ERRORS
ECHILD if the process specified in pid does not exist or
is not a child of the calling process. (This can
happen for one’s own child if the action for
SIGCHLD is set to SIG_IGN.)
ERESTARTSYS
if WNOHANG was not set and an unblocked signal or a
SIGCHLD was caught. This error is returned by the
system call. The library interface is not allowed
NOTES
The Single Unix Specification describes a flag SA_NOCLD-
WAIT (not present under Linux) such that if either this
flag is set, or the action for SIGCHLD is set to SIG_IGN
(which, by the way, is not allowed by POSIX), then chil-
dren that exit do not become zombies and a call to wait()
or waitpid() will block until all children have exited,
and then fail with errno set to ECHILD.
CONFORMING TO
SVr4, POSIX.1
SEE ALSO
signal(2), wait4(2), signal(7)
NAME
execl, execlp, execle, execv, execvp − execute a file
SYNOPSIS
#include <unistd.h>
DESCRIPTION
The exec family of functions replaces the current process
image with a new process image. The functions described
in this manual page are front−ends for the function
execve(2). (See the manual page for execve for detailed
information about the replacement of the current process.)
RETURN VALUES
If any of the exec functions returns, an error will have
occurred. The return value is −1, and the global variable
errno will be set to indicate the error.
FILES
/bin/sh
ERRORS
All of these functions may fail and set errno for any of
the errors specified for the library function execve(2).
SEE ALSO
sh(1), execve(2), fork(2), environ(5), ptrace(2)
COMPATIBILITY
On some other systems the default PATH has the current
working directory listed after /bin and /usr/bin, as an
anti−Trojan−horse measure. As of libc 5.4.7, Linux still
uses the traditional "current directory first" default
PATH.
STANDARDS
Execl, execv, execle, execlp and execvp conform to IEEE
Std1003.1−88 (‘‘POSIX.1’’).