previous | start | next

Fork Example fork01

(source)
    1   /*------------------------------------------------------------------------
    2   | 
    3   |       File: fork01.c
    4   | 
    5   |       Description: Simple program creating a child process with fork()
    6   |       and printing the return value from fork()
    7   |
    8   |       Usage: fork01
    9   | 
   10   |       Created:  5 Jan 15
   11   |       Author: glancast
   12   |       Modifications:
   13   | 
   14   +-----------------------------------------------------------------------*/
   15   #include <stdio.h>
   16   #include <stdlib.h>
   17   #include <unistd.h> // for fork
   18   
   19   int main(int argc, char* argv[])
   20   {
   21     int pid;
   22   
   23     pid = fork();
   24     printf("pid = %d\n", pid);
   25   
   26     return 0;
   27   }


previous | start | next