İşletim Sistemleri (Bahar-2016) Hafta-3
#include<iostream> #include<unistd.h> #include<sys/types.h> using namespace std; int main() { pid_t pid; cout<<"Proc id:"<<getpid()<<endl; pid=fork(); if(pid==0) // cocuk { cout<<"BEN COCUK, PROC ID:"<<getpid()<<endl; cout<<"COCUK: BEN UYUDUM"<<endl; sleep(20); cout<<"COCUK: BEN UYANDIM"<<endl; } else{ if(pid>-1) cout<<"COCUK PID:"<<pid<<endl; else cout<<"COCUK OLUSMADI"<<endl; cout<<"ANNE PID:"<<getpid()<<endl; cout<<"ANNE: BEN UYUDUM"<<endl; sleep(10); cout<<"ANNE: BEN UYANDIM"<<endl; } return 0; }