Getting ready

Besides using the keyboard within a program, we can also send signals to programs using the kill command. The kill command can kill programs, but these signals can also be used for reloading configurations or sending user-defined signals. The most common signals you may use are SIGHUP (1), SIGINT (2), SIGKILL(9), SIGTERM(15), SIGSTOP(17,18,23), SIGSEGV(12), and SIGUSR1(10)/SIGUSR2(12). The latter two can be defined within your program or leveraged by other developers. 

The kill command can be used easily as follows:

$ kill -s SIGUSR1 <processID>$ kill -9 <processID>$ kill -9 `pidof myprogram.sh`
The kill command can refer to the signal number itself or by its name. It does require a process ID number to target. This can easily ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.