fork download
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4.  
  5. int main(){
  6. pid_t pid=fork();
  7. if (pid<0){
  8. perror("fork failed");
  9. return 1;
  10. }
  11.  
  12. printf("Process ID: %d, Parent ID: %d\n", getpid(), getppid());
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
Process ID: 555037, Parent ID: 555036
Process ID: 555040, Parent ID: 1