fork download
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4. int main() {
  5. pid_t pid = fork();
  6. if (pid == 0) {
  7. printf("Child process finished.\n");
  8. } else {
  9. sleep(10); // Parent delays
  10. printf("Parent ends after child.\n");
  11. }
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Child process finished.
Parent ends after child.