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

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 &lt;&lt; &quot;k = &quot; &lt;&lt; k &lt;&lt; &quot;, parent PID=&quot; &lt;&lt; getppid() &lt;&lt; &quot;, childPID=&quot; &lt;&lt; childPID &lt;&lt; &quot;: PID &quot; &lt;&lt; getpid() &lt;&lt; &quot; now exits &quot; &lt;&lt; endl; &lt; exit(0); }...
View Full Document

This note was uploaded on 04/11/2010 for the course CECS 326 taught by Professor Staff during the Spring '08 term at CSU Long Beach.

Ask a homework question - tutors are online