fork download
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. int main()
  5. {
  6. int x = 1;
  7. int returnValue = fork();
  8. if (returnValue == 0)
  9. {
  10. printf("Child, returnValue = %d \n", getpid());
  11. printf("Child, returnValue = %d \n", returnValue);
  12.  
  13. }else
  14. {
  15. printf("Parent, returnValue = %d \n", getpid());
  16. printf("Parent, returnValue = %d \n", returnValue);
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 4528KB
stdin
Standard input is empty
stdout
Parent, returnValue = 27275 
Parent, returnValue = 27474 
Child, returnValue = 27474 
Child, returnValue = 0