SHARE
TWEET

Untitled

a guest Jun 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<unistd.h>
  3. #include<sys/types.h>
  4. #include<sys/wait.h>
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9.     pid_t pid;
  10.     for (int i = 0; i<10;i++) {
  11.         pid=fork();
  12.         if(pid==0) {
  13.             cout<<"Jestem dzieckiem, mój PID=" <<getpid()
  14.                 <<",\n pid mojego ojca to: "<<getppid()<<"\n";
  15.             execl("/usr/bin/firefox","firefox",
  16.                 "http://arXiv.org",0);
  17.                 return i;
  18.         }
  19.     }
  20.     cout<<"Jestem ojcem, mój pid="<<getpid()
  21.         <<",\n PID mojego dziecka to: "<<pid<<"\n";
  22.     int ret_status;
  23.     for(int i = 0; i < 10;i++) {
  24.         wait(&ret_status);
  25.         cout<<"Dziecko zakonczyło działanie"
  26.             <<"status="<<WEXITSTATUS(ret_status)<<"\n";
  27.     }          
  28.     return 0;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top