aboutsummaryrefslogtreecommitdiff
path: root/man/nkillall.8
blob: 65648340d3fa17baf09062bf2286b120aa7a6f9e (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
.TH nkillall 8 "Dec 28, 2009"
.SH NAME
nkillall \- send signals to all processes;  write messages to users
.SH SYNOPSIS
.B nkillall
-[vq] [-s secs] [-M|W mesg] [-signum] [-E prog [arg[s]]
.SH DESCRIPTION
.B nkillall
sends signals
to all processes skipping it's own PID.  
It is a simple program that does not use \fI/proc\fR FS.
It uses kill(2) and execve(2) syscalls.  It is designed as
a replacement of the SysVinit killall5(8) command.

.SH USAGE
It is not allowed to use
.B \-h
(signal SIGHUP) as first option!  If you really want this then start:
.B nkillall
\-s0 \-hup ...

.TP
.B \-v 
verbose mode;  \-vv means more verbose
.TP
.B \-q
quiet mode;  ignores SIGINT signal;  Ctrl-C does't work!
.TP
.B \-s 
\fIsecs\fR 
.br
sleep \fIsecs\fR
.TP
.B \-M 
\fImesg\fR
.br
write \fImesg\fR to stdout.  The message can include escape
symbols: 
\\NNN, \\a, \\b, \\e, \\c, \\f, \\n, \\r, \\t, \\v, \\\\
like in C language.  Last message can be written again with
\-M% or \-W%.  Example:

.B nkillall
\-M'\\n\\aPlease logout!  The system is going down...' \\
         \-W% \-s2 -W% \-s4 \-W% \-s12 \\
         \-M'\\tSending TERM signal' \-term ...
.TP
.B \-W
\fImesg\fR
.br
write \fImesg\fR to all logged users.  The syntax is the same as \-M.
.B nkillall
determines logged users by looking at
.I /var/run/utmp.

.br
In my opinion 
.I /var/run/utmp
is unreliable!
Other programs like who(1), wall(1), login(1) also use this file.
If you feel that yours is insecure, better don't use the \-W option.

.TP
.B \-signum
send all processes the singal \fIsignum\fR.  
Some important signals can be encodded.  For example SIGTERM can be typed with
\-15 or \-term.
Only the first letter is important!
The command
.B kill \-l
lists the signal numbers.
.TP
.B \-E
.I /path/to/program [arg[s]]
.br
execve(2) the program with some arguments.
This option must be last!  The program will have the same PID as
.B nkillall.

.SH NOTE
The options are applied immediately.  Their position is important.
The next two examples work differently:

nkillall \-q -s2 \-M'sending signal SIGTERM' \-15 ...
.br
nkillall \-s2 \-M'sending signal SIGTERM' \-15 \-q ...

Use the options \-v[v] \-q after 
.B nkillall
immediately.

.SH WARNING
.B nkillall
also kills the script in which it is included.
Use it in scripts like:

#!/bin/sh
.br
before commands
.br
exec nkillall [options] \-E/path/to/prog prog_opt(s)

An example of wrong usage is the following:

#!/bin/sh
.br
before commands
.br
nkillall ...
.br
after commands

.SH EXAMPLES
.B nkillall
\-M'Sending all processes SIGTERM ...' \-s2 \-15 \\
.br
         \-M'Sending all processes SIGKILL ...' \-s6 \-9 \\
.br
         \-s1 \-E /path/to/program arg1 arg2 ...

.B nkillall 
\-v \-s1 \-15 \-cont \-s6 \-kill \-s1 \-E/path/to/prog arg(s) ...

.B nkillall 
\-vv \-pause \-s59 \-continue \-M'Hello world!'

.SH FILES
.I /var/run/utmp

.SH AUTHOR
.B nkillall
is included in ninit package and can be downloaded from
.br
.I http://riemann.frmi.uni-sofia.bg/ninit/

.SH "SEE ALSO"
ninit(8), kill(1), kill(2), execve(2), utmp(5) 
.br
init(8), killall5(8)