fork скачать
  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 index = 0;
  7. for(int i = 0; i < 2; i++){
  8. int pid = fork();
  9. if(pid != 0){
  10. fork();
  11. printf("a");
  12. }
  13. else if(index == 0){
  14. fork();
  15. index++;
  16. printf("b");
  17. }
  18. else{
  19. fork();
  20. printf("c");
  21. }
  22. }
  23. }
Успешно #stdin #stdout 0s 5504KB
stdin
Standard input is empty
stdout
aaaaab