fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int forkRet;
  5. forkRet=fork();
  6. if(forkRet==0)
  7. {
  8. printf("In Child \n");
  9. printf("Fork Return value=%d\n",forkRet);
  10. printf("Process Id=%d ",getpid());
  11. printf("Parent Process ID=%d,getppid());
  12. }
  13. else
  14. {
  15. printf("In Parent \n");
  16. printf("Fork Return value=%d\n",forkRet);
  17. printf("Process Id=%d ",getpid());
  18. printf("Parent Process ID=%d,getppid());
  19. }
  20. return 0;
  21. }
  22.  
Compilation error #stdin compilation error #stdout 0s 2052KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:5:2: warning: implicit declaration of function 'fork' [-Wimplicit-function-declaration]
  forkRet=fork();
  ^
prog.c:10:2: warning: implicit declaration of function 'getpid' [-Wimplicit-function-declaration]
  printf("Process Id=%d ",getpid());
  ^
prog.c:11:9: warning: missing terminating " character
  printf("Parent Process ID=%d,getppid());
         ^
prog.c:11:2: error: missing terminating " character
  printf("Parent Process ID=%d,getppid());
  ^
prog.c:12:2: error: expected expression before '}' token
  }
  ^
prog.c:12:2: error: expected ';' before '}' token
prog.c:18:9: warning: missing terminating " character
  printf("Parent Process ID=%d,getppid());
         ^
prog.c:18:2: error: missing terminating " character
  printf("Parent Process ID=%d,getppid());
  ^
prog.c:19:2: error: expected expression before '}' token
  }
  ^
prog.c:19:2: error: expected ';' before '}' token
stdout
Standard output is empty