fork download
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. int main(int argc, char *argv[]){
  5. printf("A\n");
  6. int rc = fork();
  7. if (rc == 0) {
  8. printf("B\n");
  9. } else if (rc > 0){
  10. wait();
  11. printf("C\n");
  12. }
  13. rc = fork();
  14. if (rc == 0) {
  15. printf("D\n");
  16. } else if (rc > 0){
  17. wait();
  18. printf("E\n");
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
A
B
D
A
B
E
A
C
D
A
C
E