20120113

How to use fork in C++

//========================
//Program in C++ to learn fork, fork1.cpp
//========================
#include<iostream>
using namespace std;
int main()
{
int pid;
pid=fork();
if(pid==0)
{
cout<<"Inside Child \n";
cout<<"Child pid="<<pid;
}
else
{
cout<<"Inside PARENT \n";
//cout<<"Parent's Pid="<<ppid;
}
return 0;
}

No comments:

Post a Comment