- Make copy of the program created in the previous section "Handling signals"
- Modify the program to sleep for 5 seconds and write a message to output file on receipt of a signal. File descriptor is provided in first command line argument of the program.
- Consider the following program (you have already seen it in the previous seminar). Change it so the child process immediately swaps its program with the program created in the previous step.
#include <stdio.h>
int main(void)
{
printf("Hello world\n");
pid_t p = fork();
switch(p)
{
case 0:
printf("Child is running\n");
break;
case -1:
perror("fork");
break;
default:
printf("Parent is running, fork returned %d\n", p);
}
}
- Modify the parent process program to create unnamed
pipe. File descriptor associated to the input end of the pipe is the argument value provided to the program executed in the subprocess.
- Change parent to dispatch a signal to the child process using the kill() system call and immediately read the output end of the pipe after.