fork download
  1. #include <fdsf,,,``
  2.  
  3. int v=1;
  4. int main (int argc, char *argv[]) {
  5. printf(" uno %d v %d\n", getpid(), v);
  6. int p1 = fork();
  7. if(p1 == 0){
  8. v++;
  9. printf(" dos %d v %d\n", getpid(), v);
  10. fork();
  11. printf(" tres %d v %d\n", getpid(), v);
  12. execlp("ls","ls",NULL);
  13. v++;
  14. printf(" cuatro %d v %d\n", getpid(), v);
  15. fork();
  16. v++;
  17. printf(" cinco %d v %d\n", getpid(), v);
  18. exit(1);
  19. }
  20. fork();
  21. printf(" seis %d v %d\n", getpid(), v);
  22. execlp("ls","ls",NULL);
  23. v++;
  24. printf(" siete %d v %d\n", getpid(), v);
  25. fork();
  26. v++;
  27. printf(" ocho %d v %d\n", getpid(), v);
  28. wait(NULL);
  29. }
  30.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:3:33: error: ‘getpid’ was not declared in this scope
 printf(" uno %d v %d\n", getpid(), v);
                                 ^
prog.cpp:3:37: error: ‘printf’ was not declared in this scope
 printf(" uno %d v %d\n", getpid(), v);
                                     ^
prog.cpp:4:15: error: ‘fork’ was not declared in this scope
 int p1 = fork();
               ^
prog.cpp:10:18: error: ‘NULL’ was not declared in this scope
 execlp("ls","ls",NULL);
                  ^~~~
prog.cpp:10:22: error: ‘execlp’ was not declared in this scope
 execlp("ls","ls",NULL);
                      ^
prog.cpp:16:7: error: ‘exit’ was not declared in this scope
 exit(1);
       ^
prog.cpp:20:18: error: ‘NULL’ was not declared in this scope
 execlp("ls","ls",NULL);
                  ^~~~
prog.cpp:20:22: error: ‘execlp’ was not declared in this scope
 execlp("ls","ls",NULL);
                      ^
prog.cpp:26:10: error: ‘wait’ was not declared in this scope
 wait(NULL);
          ^
stdout
Standard output is empty