当前位置 博文首页 > YinhJiang的博客:Linux环境下fork()简介

    YinhJiang的博客:Linux环境下fork()简介

    作者:[db:作者] 时间:2021-08-30 12:53

    NAME
           fork - create a child process
    
    SYNOPSIS
           #include <unistd.h>
    
           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.


    cs