{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

fork2 - cout<<"k ="<< k<<" parent...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <cstdlib> #include <unistd.h> #include <iostream> using namespace std; u int main() { i int k; long childPID; l for(k=0; k<3; k++) { cout << getpid() << " is spawning a new child" << endl; if(childPID = fork()) break;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } cout << "k = " << k << ", parent PID=" << getppid() << ", childPID=" << childPID << ": PID " << getpid() << " now exits " << endl; < exit(0); }...
View Full Document

{[ snackBarMessage ]}