İşletim Sistemleri (Bahar-2016) Hafta-7/2

#include<iostream>
#include<unistd.h>
#include<sys/wait.h>
#include<stdlib.h>

using namespace std;

int main()
{
	pid_t proc_id;
	int durum;
	
	cout<<"Basla:"<<getpid()<<endl;
	
	proc_id = fork();
	
	if(proc_id==0)
	{
		// cocuk
		cout<<"Selam Ben Cocuk!"<<getpid()<<endl;
		//exit(0);
		sleep(60);
	}
	else
	{
		// anne
		waitpid(proc_id,&durum,0);
		cout<<"Sonlanma:"<<durum<<endl;
	}
	

	return 0;
}
#include<iostream>
#include<unistd.h>
#include<sys/wait.h>
#include<stdlib.h>

using namespace std;

int main()
{
	pid_t proc_id;
	int durum;
	
	cout<<"Basla:"<<getpid()<<" ::"<<SIGKILL<<endl;
	
	proc_id = fork();
	
	if(proc_id==0)
	{
		// cocuk
		cout<<"Selam Ben Cocuk!"<<endl;
		//exit(0);
	}
	else
	{
		// anne
		kill(proc_id,SIGSTOP);
		waitpid(proc_id,&durum,0);
		cout<<"Sonlanma:"<<durum<<endl;
	}
	

	return 0;
}
#include<iostream>
#include<unistd.h>
#include<sys/wait.h>

using namespace std;

int main()
{
	pid_t proc_id;
	int durum;
	
	cout<<"Basla::"<<getpid()<<endl;
	
	proc_id=fork();
	
	if(proc_id==0)
	{
		cout<<"Ben Cocuk!::"<<getpid()<<endl;
		sleep(10);
	}
	else
	{
		cout<<"Ben Anne::"<<getpid()<<" Cocugun id::"<<proc_id<<endl;
		//kill(proc_id,SIGTERM);
		kill(proc_id,SIGSTOP);
		sleep(5);
		kill(proc_id,SIGCONT);
		waitpid(proc_id,&durum,0);
		cout<<"Sonlanma::"<<durum<<endl;
	}
	
	return 0;
}
#include<iostream>
#include<unistd.h>
#include<sys/wait.h>
#include<stdlib.h>

using namespace std;

int main()
{
	pid_t proc_id;
	int durum;
	cout<<"Basla:"<<getpid()<<endl;
	proc_id = fork();
	if(proc_id==0)
	{
		// cocuk
		cout<<"Selam Ben Cocuk!"<<endl;
		int x=0, y=0;
		int z=x/y;
		sleep(50);
	}
	else
	{
		// anne
		waitpid(proc_id,&durum,0);
		cout<<"Sonlanma:"<<durum<<endl;
	}
	
	return 0;
}

 

Share