fork(1) 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. if (fork() != 0) {
  7. if (fork() != 0) {
  8. printf("hello1\n");
  9. }
  10. else {
  11. fork();
  12. }
  13. printf("hello2\n");
  14. }
  15. else {
  16. if (fork != 0) {
  17. printf("hello3\n");
  18. }
  19. else {
  20. fork();
  21. }
  22. printf("hello4\n");
  23. }
  24. printf("hello5\n");
  25. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
hello1
hello2
hello5