#include <iostream> #include <unistd.h> #include <sys/wait.h> using namespace std; void Report(); int main() { // Report(); // discussion of fork forkboomb, // a little deadlock/race condition /* int i = 0; while (i < 6) { pid_t newid { fork()}; // newid = fork(); // call fork() // mov [newid], rax if (newid == 0) { i = 6; } else { ++i; } } */ if (fork() == 0) { cout << "Sleeping " << endl; sleep(1); cout << "Done Sleeping" << endl; Report(); return 0; } wait(nullptr); Report(); return 0; } void Report() { pid_t pid{getpid()}; pid_t ppid{getppid()}; cout << endl; cout << " My process id is " << pid << endl; cout << " My parent process id is " << ppid << endl; cout << endl; }