yo/concrete/examples/fork.cc
raw| 1 | #include "fork.ih" |
| 2 | |
| 3 | void Fork::fork() |
| 4 | { |
| 5 | if ((d_pid = ::fork()) < 0) |
| 6 | throw "Fork::fork() failed"; |
| 7 | |
| 8 | if (d_pid == 0) // childprocess has pid == 0 |
| 9 | { |
| 10 | childRedirections(); |
| 11 | childProcess(); |
| 12 | exit(1); // we shouldn't come here: |
| 13 | } // childProcess() should exit |
| 14 | |
| 15 | parentRedirections(); |
| 16 | parentProcess(); |
| 17 | } |