#include #include #include #include #include #include "err.h" using namespace std; int main () { pid_t pid; cout << "My process id = " << getpid() << endl; switch (pid = fork()) { case -1: syserr("Error in fork"); case 0: cout << "Child process: My process id = " << getpid() << endl; cout << "Child process: Value returned by fork() = " << pid << endl; return 0; default: cout << "Parent process. My process id = " << getpid() << endl; cout << "Parent process. Value returned by fork() = " << pid << endl; if (wait(NULL) == -1) syserr("Error in wait"); return 0; } /*switch*/ }