Your program should create a counter variable. Counting details in part 1. When the programfinally completes, the program should output the number of times the user depressed CTRL-C.(1) The first is to handle the SIGINT (CTRL-C, ^C) signal. This signal handler should incrementthe counter.The signal handler should also contain a MAX value (say 5) that is used. In the case thatthe maximum is reached:• a message indicating that the MAX has been exceeded should be output• the signal handler should be "deactivated" so that the next instance of the ^Csignal causes the program to terminate.(2) The second signal handler should deal with the SIGQUIT signal (CTRL-\, ^\). If the usersends this signal, the signal handler should create a new process (fork).This child process should print a message and then send a SIGUSR1 signal (using kill())to its parent. The child should terminate with no error code. This must be accomplishedwithout using any of the exec() family of calls.The parent side of the fork() should just exit the signal handler without doing anything.(3) The final signal handler (for the parent) should catch the SIGUSR1 signal (sent by the childprocess in part 2). This handler should print a message that the program is over and then exit.The parent should simply wait for the child to terminate, then exit gracefully.The main program should contain a loop forever waiting for a signal (i.e. pause).

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter5: Looping
Section: Chapter Questions
Problem 3RQ
icon
Related questions
Question

Your program should create a counter variable. Counting details in part 1. When the program
finally completes, the program should output the number of times the user depressed CTRL-C.
(1) The first is to handle the SIGINT (CTRL-C, ^C) signal. This signal handler should increment
the counter.
The signal handler should also contain a MAX value (say 5) that is used. In the case that
the maximum is reached:
• a message indicating that the MAX has been exceeded should be output
• the signal handler should be "deactivated" so that the next instance of the ^C
signal causes the program to terminate.
(2) The second signal handler should deal with the SIGQUIT signal (CTRL-\, ^\). If the user
sends this signal, the signal handler should create a new process (fork).
This child process should print a message and then send a SIGUSR1 signal (using kill())
to its parent. The child should terminate with no error code. This must be accomplished
without using any of the exec() family of calls.
The parent side of the fork() should just exit the signal handler without doing anything.
(3) The final signal handler (for the parent) should catch the SIGUSR1 signal (sent by the child
process in part 2). This handler should print a message that the program is over and then exit.
The parent should simply wait for the child to terminate, then exit gracefully.
The main program should contain a loop forever waiting for a signal (i.e. pause). 

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,