![]() |
[ غير ذلك ] بليز الا يعرف لنظام linux Your objective is to write a C program sig.c that, when invoked, waits for input from the user and echoes it back line-by-line While echoing inputs, your program should also listen for several signals. Receipt of each signal should cause a different response from the program. First, your program 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: 1. SIGINT should print a summary of all time spent by the program (system and user) and then continue running the program. 2. SIGTERM should print a summary of all time spent in the program, and additionally exit the program 3. SI 4. GTSTP should print the last 10 lines of user input. Hints Some documentation pointers • 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. ............................................ implement the above using only one signal handler routine to catch all kinds of signals. |
| الساعة الآن 01:29 PM |
Powered by vBulletin® Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.2 TranZ By
Almuhajir