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).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education