fork download
  1. // Online C compiler to run C program online
  2. #include <stdio.h>
  3. #include <sys/types.h>
  4. #include <unistd.h>
  5. #include<sys/wait.h>
  6. #include<stdlib.h>
  7. int main()
  8. {
  9. int pid;
  10. pid=fork();
  11. if(pid<0)
  12. {
  13. printf("fork failed\n");
  14. exit(1);
  15. }
  16. else if(pid==0)
  17. {
  18. execlp("PESCE","AI&ML",NULL);
  19. exit(0);
  20. }
  21. else
  22. {
  23. printf("\n process Id is :%d\n",getpid());
  24. wait(NULL);
  25. exit(0);
  26. }
  27. }
  28.  
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
 process Id is :3491178