// Aaron Linville // aaron@linville.org // http://www.linville.org // fork.cpp - Identify Parents and Children #include #include #include int main() { int stat_loc, pid; if ((pid = fork()) == -1) { cerr << "Unable to fork!" << endl; } else { if (pid == 0) { cout << "I am the child! My PID is " << getpid() << endl; } else { cout << "I am the parent! My PID is " << getpid() << endl; wait(&stat_loc); } } return 0; }