/* createProc5a.c++ death of parent */ #include using namespace std; #include #include #include #include #include int main() { // createProc5a.c++ int chPID; chPID = fork(); if(chPID == -1){ cerr << "fork() failed\n"; return 0; } if(chPID > 0) { // parent sleep(1); cout << "In parent: parent pid = " << getpid() << "\n" << "\tIn parent: child pid = " << chPID << "\n" ; } else { // child cout << "In child: child pid = " << getpid() << "\n" << "\tIn child: parent pid = " << getppid() << "\n" ; sleep(5); cout << "Again in child: child pid = " << getpid() << "\n" << "\tIn child: parent pid = " << getppid() << "\n" ; } return 0 ; }