1
0
UAHCode/CPE435/Lab1/lab1.cpp

21 lines
468 B
C++
Raw Normal View History

2022-08-28 21:12:16 +00:00
using namespace std;
#include <iostream>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
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);
}