Question
use signals to interacting with processes. write two C program sig.c that 1.implement using only one signal handler routine to catch all kinds of signals
use signals to interacting with processes.
write two C program sig.c that
1.implement using only one signal handler routine to catch all kinds of signals
2.implement using as many handlers as you choose.
when invoked, waits for input from the user and echoes it back line-by-line (this is the default behavior). These two programs should execute on a Linux machine, and should be compiled with gcc. While echoing inputs, the programs should also listen for several signals. Receipt of each signal should cause a different response from the program.
First, the programs should schedule a SIGALRM (alarm) every ten seconds, and react to this signal by counting up seconds, by printing something like the following:
tick 0...
tick 10...
tick 20...
as a running count. This will serve as a "heartbeat" to let you know that your program has not crashed.
Second, the following signals should evoke behaviors as indicated:
SIGINT should print a summary of all time spent by the program (system and user) and then continue running the program.
SIGTERM should print a summary of all time spent in the program, and additionally exit the program
SIGTSTP should print the last 10 lines of user input.
Third, use the folllowing documentation:
man signal - how to set up a signal handler.
man sigvec - another way to set up a signal handler.
man sleep - how to use SIGALRM to sleep for a given number of seconds.
The whole program should be in a single c program sig.c. The beginning of the file should describe how to compile the file, in comments.
(A typical compilation command might be: gcc -o sig sig.c)
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