#include #include #include using namespace std; int main() { pid_t id; string myName = "\tPARENT:"; cout << "Before fork, my id is " << getpid() << endl; id = fork(); if (!id) { myName = "\tCHILD:"; cout << myName << " After the fork, my id is " << getpid() << endl; cout << myName << " My parent id is " << getppid() << endl; cout << myName << " The return value was " << id << endl; } else { cout << myName << " After fork, I am the parent" << endl; cout << myName << " The child id is " << id << endl; } cout << myName << " out of the loop and about to exit " << endl; return 0; }