#include #include #include using namespace std; int main() { pid_t pid; pid = fork(); if (pid == -1 ) { perror("Fork failed"); return 1; } if (pid == 0) { cout << "Child here, my parent id is " << getppid() << endl; sleep(2); cout << "Child here, my parent id is " << getppid() << endl; } else { sleep(1); cout << "Parent exiting, but hang on for a second" << endl; } return 0; }