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 #include #include #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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!