user6413315
user6413315

Reputation:

Command KILL can send all signals?

I wondered if all the signals could potentially be sent on a process with the Kill command.

I have looked at the manual of Kill and Signal (section 7) but I don't know if the signals present in Linux can all be used with Kill.

thanks

Upvotes: 3

Views: 1403

Answers (3)

Ana Beltran
Ana Beltran

Reputation: 71

We can send signal to process by with

kill -signal pid1 [pid2 ... pidn]

kill -9 1379 3001

or you can send signal by name to a set of process

killall -s signal processname

killall -s SIGTERM firefox

However, how the process uses the signal depends of if the this one is in the same user space and if the signal can be catched by the process.

We have a lot of possible signals, manually catched or ignored and other, must by attended.

But others, depends on how you programmed to respond to the signal.

Upvotes: 0

Samuel G. P.
Samuel G. P.

Reputation: 3084

Yes, it can.

You can use it like this:

kill [options] <pid> [...]

Example:

kill -USR1 6127

This will send the USR1 signal to process with pid 6127

Or else with signals numbers:

kill -9 6127

All this is detailed on kill manual and you can see it typing man kill on your terminal, the output will be something like this:

NAME kill - send a signal to a process

SYNOPSIS kill [options] [...]

DESCRIPTION The default signal for kill is TERM. Use -l or -L to list available signals. Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0. Alternate signals may be specified in three ways: -9, -SIGKILL or -KILL. Negative PID values may be used to choose whole process groups; see the PGID column in ps command output. A PID of -1 is special; it indicates all processes except the kill process itself and init.

You can type kill -l to see a short list of signals or you can take a look at the signal(7) manual with man 7 signal to see a complete list of signals with descriptions:

Standard signals Linux supports the standard signals listed below. Several signal numbers are architecture-dependent, as indicated in the "Value" column. (Where three values are given, the first one is usually valid for alpha and sparc, the middle one for x86, arm, and most other architectures, and the last one for mips. (Values for parisc are not shown; see the Linux kernel source for signal numbering on that architecture.) A - denotes that a signal is absent on the corresponding architecture.)

   First the signals described in the original POSIX.1-1990 standard.

   Signal     Value     Action   Comment
   ──────────────────────────────────────────────────────────────────────
   SIGHUP        1       Term    Hangup detected on controlling terminal
                                 or death of controlling process
   SIGINT        2       Term    Interrupt from keyboard
   SIGQUIT       3       Core    Quit from keyboard
   SIGILL        4       Core    Illegal Instruction
   SIGABRT       6       Core    Abort signal from abort(3)
   SIGFPE        8       Core    Floating point exception
   SIGKILL       9       Term    Kill signal
   SIGSEGV      11       Core    Invalid memory reference
   SIGPIPE      13       Term    Broken pipe: write to pipe with no
                                 readers
   SIGALRM      14       Term    Timer signal from alarm(2)
   SIGTERM      15       Term    Termination signal
   SIGUSR1   30,10,16    Term    User-defined signal 1
   SIGUSR2   31,12,17    Term    User-defined signal 2
   SIGCHLD   20,17,18    Ign     Child stopped or terminated
   SIGCONT   19,18,25    Cont    Continue if stopped
   SIGSTOP   17,19,23    Stop    Stop process
   SIGTSTP   18,20,24    Stop    Stop typed at terminal
   SIGTTIN   21,21,26    Stop    Terminal input for background process
   SIGTTOU   22,22,27    Stop    Terminal output for background process

   The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.

And a lot of more info about signals. ;)

Upvotes: 5

khrm
khrm

Reputation: 5753

Yes, you can. There are many ways. Simplest way is:

kill -signalnumber  pid1 pid2 ...

Upvotes: 1

Related Questions