Question
#include int ntimes = 0; main() { pid_t pid, ppid; void p_action(int), c_action(int); static struct sigaction pact, cact; pact.sa_handler = (a) _______; sigaction((b) _______, &pact,
#include
int ntimes = 0;
main()
{
pid_t pid, ppid;
void p_action(int), c_action(int);
static struct sigaction pact, cact;
pact.sa_handler = (a) _______;
sigaction((b) _______, &pact, NULL);
switch(pid = fork()) {
case -1: /* error */
perror("synchro");
exit(l);
case 0: /* child */
/* set action for child */
cact.sa_handler = (c)_______;
sigaction((d)______, &cact, NULL);
/* get parent process-id */
ppid = getppid();
for (;;)
{
(e)________ ;
sleep(1);
(f)________;
}
/* never exits */
default: /*parent */
for(;;)
{
sleep(1);
(g)__________;
(h)_________;
}
/* never exits */
}
}
void p_action(int sig)
{
printf("Parent caught signal #%d ", ++ntimes);
}
void c_action(int sig)
(
printf("Child caught signal #%d ", ++ntimes);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started