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 5284KB
stdin
Standard input is empty
stdout
Process ID: 562563, Parent ID: 562562
Process ID: 562566, Parent ID: 1