Question
Modify the codes to work in the following way: Both the Parent process and the Child process send a Signal to each other after a
Modify the codes to work in the following way: Both the Parent process and the Child process send a Signal to each other after a short duration (2 seconds). You can add delays using sleep(). When Parent sends the Signal: Parent shows: "Parent: Boss sent message ", Child shows: "Child: Okay Boss, I will start working. " When Child sends the Signal: Parent shows: "Parent: Work done, Boss Happy ", Child shows: "Child: Boss, I have completed the work. "
Code:
#include
void sig_handle() { printf("Someone is trying to kill me "); }
int main() { pid_t pid; pid = fork(); if (pid == 0) { signal(SIGINT, sig_handle); while (1) { printf("Child Running. "); } } else { sleep(2); printf (" Child Process will be killed now."); kill (pid, SIGINT); } return 0; }
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