Linux 环境中的fork()使用简介

NAME
       fork - create a child process

SYNOPSIS
       #include 

       pid_t fork(void);

DESCRIPTION
       fork()  creates a new process by duplicating the calling process.  The
       new process is referred to as the child process.  The calling  process
       is referred to as the parent process.

       The  child  process and the parent process run in separate memory spa‐
       ces.  At the time of fork() both memory spaces have the same  content.
       Memory  writes,  file  mappings  (mmap(2)), and unmappings (munmap(2))
       performed by one of the processes do not affect the other.
RETURN VALUE
       On  success,  the  PID of the child process is returned in the parent,
       and 0 is returned in the child.  On failure, -1  is  returned  in  the
       parent, no child process is created, and errno is set appropriately.


你可能感兴趣的:(C)