-
Notifications
You must be signed in to change notification settings - Fork 151
/
kill.sh
61 lines (39 loc) · 1.46 KB
/
kill.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# POSIX 7
# On Ubuntu 12.04, implemented by the procps package.
# Kill exists as a bash built-in.
# One of the reasons for this is to allow users to `kill` by jobspec for example as `sleep 1- &; kill %1`,
# Which an external executable could not do. Killin gby PID is required by POSIX 7.
# Send signals to a process. Signals are an ANSI C concept, with POSIX and Linux extensions.
# Does not necessarily send SIGKILL, nor is SIGKILL the default signal sent!
# The default signal it sends is SIGTERM.
# It is unfortunatelly named kill because most signals end up killing process,
# or also because the most used signal is SIGTERM generated by a C-C on the terminal.
# which has the usual effect of killing a process.
# List all signals available on the system:
kill -l
# Lists numbers and descriptions.
# Send SIGTERM signal to process:
ps -A
ID=
kill $ID
# SIGTERM is the default signal sent by `kill`.
# Select by pid, found on ps for example.
# Select by job-id found on jobs:
sleep 10 &
jobs
kill %1
# POSIX specifies this.
# Send stop signal to process:
kill -s SIGSTOP $ID
kill -s sigstop $ID
kill -s STOP $ID
kill -s stop $ID
# All of the above are specified by POSIX.
# Where `SIGSTOP` is the standard signal name.
# Also possible with the XSI extension:
kill -SIGSTOP $ID
kill -sigstop $ID
kill -STOP $ID
kill -stop $ID
# But not recommended because it is less uniform parameter passing,
# and not guaranteed to be on all implementations.