fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C/C++.
  5. Code, Compile, Run and Debug online from anywhere in world.
  6.  
  7. *******************************************************************************/
  8. #include <stdio.h>
  9. #include<unistd.h>
  10.  
  11. int main()
  12. {
  13. int pid = fork();
  14. if (pid !=0){
  15. printf("hello from parent %d ", getpid());
  16.  
  17. }
  18. else if (pid == 0){
  19. printf("hello from child %d", getpid() );
  20.  
  21. }
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5516KB
stdin
45
stdout
hello from parent 32569 hello from child 32590