using namespace std; #include #include #include #include int main(int argc, char * argv[]) { pid_t x; cout << "The pid of the parent is " << getpid() << endl; for(int i=0; i<10; i++){ x = fork(); if (x == 0 ) /* we are the child */ { cout << "Id: " << getpid() << "\tX: x "<< endl; exit(0); } // cout << "I am the parent, the child's pid is " << x << endl; } exit(0); }