6

I saw this Command on a Book for Linux shell Scripting

$ kill -HUP 1234 >killout.txt 2>killerr.txt

I know what the command does, but i am not able to understand the flags -HUP

1

2 Answers 2

6

Under Linux try man 7 signal.

kill -HUP 1234 means "send the SIGHUP signal (1) to process 1234", so it's equivalent to kill -1 1234. The default signal that is sent by kill is SIGTERM (15), so kill 1234 is equivalent to kill -TERM 1234 or kill -15 1234.

1
  • 1
    Note that the POSIX syntax is kill -s HUP. kill -HUP and kill -1 are Unix (XSI extension in the SUS) but not POSIX. Note that kill -s HUP and kill -1 are the same as per Unix, but the signal number for HUP is not guaranteed to be 1 (in case you expect a process killed with HUP to return an exit status of 129 or 257) May 5, 2013 at 20:38
4

-HUP isn't the three flags H, U, P as in the common single-letter option syntax. For historical reasons, the kill command takes an optional signal name or signal number preceded by a dash (-).

kill -1 1234
kill -HUP 1234

(As opposed to kill 1 1234, which would send the default signal (SIGTERM) to processes 1 and 1234.)

Your man page probably lists something like this:

kill [ -signal | -s signal ] pid ...

That -signal means that you can use a dash followed by a signal designation (which can be a name or number). Alternatively, you can use the -s option followed by a signal name; these are two different syntaxes with the same meaning.

kill -l lists the available signal names and the corresponding numbers.

Most signals have a predefined meaning based on who sends them when and how processes are supposed and able to react to them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .