#include #include #include using namespace std; int main(){ pid_t mypid{getpid()}; cout << "The parent has pid " << mypid << endl; pid_t orphan{fork()}; if (orphan != 0) { // parent here mypid = getpid(); cout << "\tThe parent has pid " << mypid << endl; usleep(1000); cout << "\tThe parent will exit " << endl; return 0; } cout << "Child here, my parent is " << getppid() << endl; cout << "Press any key to continue" << endl; cin.ignore(1000,'\n'); cout << "Child here, my parent is now " << getppid() << endl; return 0; }