About Red Hat Partner Programmes Training Support and Docs Products and Services
  downloadstorecart
red hat logo search    
redhat.comredhat network
Red Hat Documentation: man pages: man2: Linux Programmer's Manual (2)

Manpage of FORK

FORK

Section: Linux Programmer's Manual (2)
Updated: 10 June 2025
Index  

NAME

fork, vfork - create a child process  

SYNOPSIS

#include <unistd.h>

pid_t fork(void);
pid_t vfork(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 pending signals are not inherited.

Under Linux, fork is implemented using copy-on-write pages, so the only penalty incurred by fork is the time and memory required to duplicate the parent's page tables, and to create a unique task structure for the child.  

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.
ENOMEM
fork failed to allocate the necessary kernel structures because memory is tight.
 

BUGS

Under Linux, vfork is merely an alias for fork.  

CONFORMING TO

The fork call conforms to SVr4, SVID, POSIX, X/OPEN, BSD 4.3.  

SEE ALSO


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
BUGS
CONFORMING TO
SEE ALSO

This document was created by using the manual pages.
Time: 11:56:05 GMT, March 24, 2025

 

 
 
© 2001 Red Hat, Inc. All rights reserved.       About Red Hat   :   Legal statement   :   Privacy statement   :   Y2K statement   :   Contact Red Hat