Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <iostream>
  5. #include <sys/types.h>
  6.  
  7. using namespace std;
  8.  
  9. int main(){
  10.   pid_t pid;
  11.   pid = fork();
  12.  
  13.   if(pid < 0){
  14.     cout<<"Fork Failed";
  15.     return 1;
  16.   }else if(pid == 0){
  17.     cout<<"Child class pid = "<<getpid();
  18.   }else{
  19.     cout<<"Parent class pid = "<<getppid()<<endl;
  20.   }
  21.   return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement