Question: Develop a program that uses system call int kill(pid_t pid, int sig) to deliver signal SIGINT and signal SIGHQUIT. Provide pid_t pid from command line

  1. Develop a program that uses system call int kill(pid_t pid, int sig) to deliver signal SIGINT and signal SIGHQUIT. Provide pid_t pid from command line to the program. Let the process sleep 3 seconds between delivering signal SIGINT and signal SIGHQUIT. Then run Program Example 4.4 at the end of Lecture 4 as a background job. Use your program to deliver signal SIGINT and signal SIGHQUIT to the process of Program Example 4.4.

Example 4.4 given ..

#include #include #include #include int main() { int i; void signal_catcher(int); if (signal(SIGINT, signal_catcher) ==SIG_ERR) { perror("SIGINT"); exit(1); } if (signal(SIGQUIT, signal_catcher) ==SIG_ERR) { perror("SIGQUIT"); exit(2); } for (i=0; ; ++i) { printf("%i ", i); sleep(1); } } void signal_catcher(int the_sig) { signal(the_sig, signal_catcher); /*reset*/ printf(" Signal %d received. ", the_sig); if (the_sig == SIGQUIT) exit(3); }

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!