fork(4) download
  1. #include <iostream>
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. cout<<"*"<<endl;
  11. if (fork()==-1) cout << "fork1 failed()" << endl;
  12. cout<<"A\n";
  13. if (fork()==-1) cout << "fork2 failed()" << endl;
  14. cout<<"B\n";
  15. if (fork()==-1) cout << "fork3 failed()" << endl;
  16. cout<<"C\n";
  17. return 0;
  18. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
*
A
B
C
A
B
C