Untitled

 avatar
unknown
plain_text
2 years ago
759 B
4
Indexable
/* suspending and resuming processes using signals.*/
#include<stdio.h>
#include<unistd.h>
#include <stdlib.h>
#include<sys/types.h>
#include<signal.h>
int main ()
{
int pid,p1,p2;
pid=fork(); // create the process
if(pid==-1)
{
printf("\n Error in creation:"); // error
exit(1);
}
if (pid!=0)
{
printf("\n Child process\n");
p1=getpid(); // get the process id
printf("\n child process is :% d",p1);
printf("\n Parent process");
p2=getppid(); // get the parent process id
printf("\n parent process is :% d",p2);
}
//suspend the process(same as hitting crtl+z)
printf("\nchild process is stopped using signal\n");
kill(p1,SIGSTOP);
//continue the process
printf("\n child process is conitue using signal\n");
kill(p1,SIGCONT);
}
Editor is loading...