C language programming assignment

Rock1027

Write a program called signal.c that performs the functions of the standard UNIX kill command.  We will call our program signal instead of kill so that it is clear we are not calling the built-in or standard kill command included on most systems).

The program should perform as follows:

1. If no command line arguments are provided, it should display the following usage information:

$ ./signal
Usage: ./signal [options] <pid>

Options:
   -s <signal>   Sends <signal>  to <pid>
   -l            Lists all signal numbers with their names

2. If no specific signal is provided using -s, then the SIGTERM is sent to the specified pid by default:

$ ./signal 1289

3. If a specific signal is provided using -s, then that signal is sent to the specified pid instead of TERM:

$ ./signal -s 9 1289

4. If the special (non) signal number 0 is specified, report if the specified pid exists and is able to receive signals.  For example, assuming pid 1289 exists and is ours, 1432 does not exist, and 1 (of course) exists and is not ours:

$ ./signal -s 0 1289
PID 1289 exists and is able to receive signals

or

$ ./signal -s 0 1432
PID 1432 does not exist

or

$ ./signal -s 0 1
PID 1 exists, but we can't send it signals

Hint: Refer to the following manual pages for helpful details:

$ man 2 kill
$ man 3 errno

Upload your code (do your own work!) here as a single C file named abc123_signal.c

    • 8 years ago
    • 30
    Answer(2)

    Purchase the answer to view it

    NOT RATED
    • killcommand.zip

    Purchase the answer to view it

    NOT RATED
    • abc123_signal.c
    • Hello.docx