Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions