fork download
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. #include <stdlib.h>
  5.  
  6. int main()
  7. {
  8. if (fork() > 0)
  9. {
  10. printf("Parent exiting using exit()\n");
  11. exit(0);
  12. }
  13. else
  14. {
  15. sleep(4);
  16. printf("Child process running, PPID = %d\n", getppid());
  17. }
  18.  
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Parent exiting using exit()