fork download
  1. /* main program illustrating the UNIX fork() system call.
  2. Compile using cc -o main main.c
  3. */
  4. #include <stdio.h>
  5. main() {
  6. int childpid, value;
  7.  
  8. childpid = fork();
  9. fork();/* create a new process */
  10. printf("\nmy_process_id=%d,my_child’s_process_id=%d",getpid(), childpid);
  11.  
  12. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
my_process_id=1077482,my_child’s_process_id=1077485
my_process_id=1077486,my_child’s_process_id=1077485
my_process_id=1077485,my_child’s_process_id=0