SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int childPid;
  6.  
  7.     if ((childPid = fork()) == -1)
  8.     {
  9.         fprint(stderr, "can't fork\n");
  10.         exit(1);
  11.     }
  12.     else if (childPid == 0)
  13.     {
  14.         fprintf(stdout, "child: child pid = %d, parent pid = %d\n",
  15.             getpid(), getppid());
  16.         exit(0);
  17.     }
  18.     else
  19.     {
  20.         fprintf(stdout, "parent: child pid = %d, parent pid = %d\n",
  21.             childPid, getpid());
  22.         exit(0);
  23.  
  24.     }
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top