Skip to content

Instantly share code, notes, and snippets.

@archi144
Created October 18, 2019 18:17
Show Gist options
  • Save archi144/217183f647574033ebd1673846df9c3f to your computer and use it in GitHub Desktop.
Save archi144/217183f647574033ebd1673846df9c3f to your computer and use it in GitHub Desktop.
int main(int argc,char* argv[])
{
cout<<"\nРодительский PID: " << getpid()<< "\nРодительский PPID: "<< getppid()<< "\nРодительский GPID: "<< getgid() << endl;
int status = fork();
if(status)
{
cout<<"\nВыполняется родительский процесс..."<<endl;
cout<<"\nВозвращаемый код fork: " << status << endl;
cout<<"Родительский PID: " << getpid()<< "\nРодительский PPID: "<< getppid()<< "\nРодительский GPID: "<< getgid() << endl;
pause();
}
else
{
cout<<"\nВыполняется дочерний процесс..."<<endl;
cout<<"\nВозвращаемый код fork: " << status << endl;
cout<<"Дочерний PID: " << getpid()<< "\nДочерний PPID: "<< getppid()<< "\nДочерний GPID: "<< getgid() << endl;
pause();
}
cout<<"status : "<<status<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment