#include #include #include using namespace std; int main() { void showIDs(int, string); int childPid = fork(); if (childPid == 0) { showIDs(childPid, string("I am the child")); } else if (childPid > 0) { // sleep(10); showIDs(childPid, string("I am the parent")); } else cout << "fork was not successful" << endl; return 0; } void showIDs(int childPid, string msg) { cout << msg << " (pid=" << getpid() << ", ppid=" << getppid() << ", child=" << childPid << ")" << endl; }