C Language : fork () function

# Include <unistd.h>
<stdio.h> # include

int main ( void ) { int i = 0 ; printf ( "i Son / PA ppid pid FPID \ N " ); / / ppid parent process refers to the current process pid / / pid pid refers to the current process, / / FPID refers to fork back to the current process value for ( i = 0 ; i < 2 ; i + + ) { pid_t FPID = fork (); if ( FPID == 0 ) printf ( "% d% Child% 4D% 4D 4D \ N " , i , getppid (), getpid (), FPID ); else printf ( "% d parent% 4D% 4D% 4D \ N " , i , getppid () , getpid (), FPID ); } return 0 ; }


Learn More :