| Age | Commit message (Collapse) | Author | Files | Lines |
|
Signed-off-by: fortunate-lee <lijian01@kylinos.cn>
|
|
Signed-off-by: Leefancy <lijian01@kylinos.cn>
|
|
It helps using kill -l/-L in a script.
$ ./kill -L
1 HUP 2 INT 3 QUIT 4 ILL 5 TRAP
6 ABRT 6 IOT 7 BUS 8 FPE 9 KILL
...
$ ./kill -L | cat
1 HUP
2 INT
3 QUIT
...
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
|
|
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
|
|
The 6.9 Linux kernel added support for pidfds which introduces inodes
that stay unique for the system lifetime and can be used to reference
a process with both its traditional pid and pid fd inode number.
This enables race-free killing of processes and protects from false
referencing due to pid rollovers.
This patch adds a new way of addressing processes with the format
'pid:pidfd_inode'. When the new format is used, 'kill' assumes the user wishes
to use a pidfd to signal a process, and will therefore use pidfd_* routines
to complete the task if the provided inode matches the one from a previously
acquired pidfd.
Addresses: #3252
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
|
|
Insert 'that' so the sentence reads '... only option that can be
used with other options.' Comment-only change; no functional impact.
Signed-off-by: Naoki Wake <wakeke.rainbowearth@gmail.com>
|
|
Increase the indentation of the continuation line from one to two
spaces to match the common util-linux help style (see
Documentation/howto-usage-function.txt). This touches a translatable
string. Whitespace-only change; no functional impact.
Signed-off-by: Naoki Wake <wakeke.rainbowearth@gmail.com>
|
|
Having four different forms for the same basic message is unneeded.
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
|
|
* remove global UL_HAVE_PIDFD, in many cases we need only subset of pidfd
kernel API, rrather than all the functios
* improve #ifdefs for pidfd_*() direct syscalls
* improve dummy fallback to not redefine system header files
Fixes: https://github.com/util-linux/util-linux/issues/3437
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Bitfields have their uses, but the uses here didn't make any sense.
Code generated to read or write bitfields is more complicated (and
slower) because, well, the bits need to be manipulated with special
instructions. So bitfields should be used when we have a structure
that is repeated hundreds or thousands of times in memory and those
saving are higher than the cost of having more complicated code. This
can happen for example in the kernel code. But the code here has
structures that are instantiated once or or at most few times.
In addition, a bitfield often does not save any memory because of
alignment requirements. In the majority of cases modified here, the
bitfield was the last field in a structure, so no memory savings were
made.
$ size build*/{mkswap,more,ul,col,rtcwake,lsmem,lscpu,eject,dmesg,uuidd,taskset,login}
text data bss dec hex filename
132014 1988 88 134090 20bca build/mkswap
129342 1852 88 131282 200d2 build2/mkswap
55161 1480 128 56769 ddc1 build/more
54265 1480 128 55873 da41 build2/more
14364 868 112 15344 3bf0 build/ul
14316 868 112 15296 3bc0 build2/ul
28547 1000 112 29659 73db build/col
28435 1000 112 29547 736b build2/col
46914 1960 112 48986 bf5a build/rtcwake
46834 1960 112 48906 bf0a build2/rtcwake
63419 1744 176 65339 ff3b build/lsmem
63403 1744 176 65323 ff2b build2/lsmem
159885 2864 464 163213 27d8d build/lscpu
159757 2864 464 163085 27d0d build2/lscpu
90041 1704 88 91833 166b9 build/eject
89737 1704 88 91529 16589 build2/eject
82150 5152 1032 88334 1590e build/dmesg
81846 5152 1032 88030 157de build2/dmesg
37601 1368 80 39049 9889 build/uuidd
37585 1368 80 39033 9879 build2/uuidd
58906 1336 56 60298 eb8a build/taskset
58890 1336 56 60282 eb7a build2/taskset
84761 2128 152 87041 15401 build/login
84672 2128 152 86952 153a8 build2/login
(To be clear: those small savings are not particularly important. The
motivation for this patch is to eradicate the antipattern of making
things more complicated without any benefit.)
|
|
|
|
A good start. Some lines moved because they were under a misspelled duplicate heading.
|
|
-l/--list option is extended to work well with the output of ps command:
$ ps s $$
UID PID PENDING BLOCKED IGNORED CAUGHT STAT TTY TIME COMMAND
1000 1588189 0000000000000000 0000000000010000 0000000000384004 000000004b813efb S pts/56 0:00 bash
$ ./kill --list 0x000000004b813efb
HUP
INT
ILL
TRAP
ABRT
...
If you know the pid you are interested in, you can skip running ps
comman with -d/--show-process-state option:
$ ./kill --show-process-state $$
Blocked: INT
Ignored: TERM TSTP TTIN TTOU
Caught: HUP INT PIPE ALRM CHLD WINCH
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
|
|
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
|
|
In production we've had several incidents over the years where a process
has a signal handler registered for SIGHUP or one of the SIGUSR signals
which can be used to signal a request to reload configs, rotate log
files, and the like. While this may seem harmless enough, what we've
seen happen repeatedly is something like the following:
1. A process is using SIGHUP/SIGUSR[12] to request some
application-handled state change -- reloading configs, rotating a log
file, etc;
2. This kind of request is deprecated and removed, so the signal handler
is removed. However, a site where the signal might be sent from is
missed (often logrotate or a service manager);
3. Because the default disposition of these signals is terminal, sooner
or later these applications are going to be sent SIGHUP or similar
and end up unexpectedly killed.
I know for a fact that we're not the only organistion experiencing this:
in general, signal use is pretty tricky to reason about and safely
remove because of the fairly aggressive SIG_DFL behaviour for some
common signals, especially for SIGHUP which has a particularly ambiguous
meaning. Especially in a large, highly interconnected codebase,
reasoning about signal interactions between system configuration and
applications can be highly complex, and it's inevitable that on occasion
a callsite will be missed.
In some cases the right call to avoid this will be to migrate services
towards other forms of IPC for this purpose, but inevitably there will
be some services which must continue using signals, so we need a safe
way to support them.
This patch adds support for the -r/--require-handler flag, which checks
if a userspace handler is present for the signal being sent. If it is
not, the process will be skipped.
With this flag we can enforce that all SIGHUP reload cases and SIGUSR
equivalents use --require-handler. This effectively mitigates the case
we've seen time and time again where SIGHUP is used to rotate log files
or reload configs, but the sending site is mistakenly left present after
the removal of signal handler, resulting in unintended termination of
the process.
Signed-off-by: Chris Down <chris@chrisdown.name>
|
|
|
|
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Found with readability-else-after-return
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
Found with readability-redundant-control-flow
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
At times there is need in scripts to send multiple signals to a process.
Often these cases require some amount of waiting before follow-up signal
should be sent.
One common case is process termination, where first script tries to kill
process gracefully but if that does not work SIGKILL is sent. Functionality
like that is commonly done by periodically checking if signalled pid exist
or not, and if it does another signal is sent possibly to an unrelated
process that reused pid number. That means polling a pid is prone to a data
race. Also if the first signal immediately kills the process one polling
interval is lost in sleep.
Another example when multiple signal need to be sent is various daemon
process control situations, such as Upgrading Executable on the Fly (see
reference). This happens to be the case that inspired change author to make
sequential signaling a little bit easier.
Reference: http://nginx.org/en/docs/control.html#upgrade
Pull-request: https://github.com/karelzak/util-linux/pull/902
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
|
|
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Removal was promised to happen in March 2016 and the time has come to get
rid of this unexpected feature.
Reference: c5b057b3422504a671ee588fa66574ae876521f1
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
|
|
Almost any code calling get_terminal_width() checks returned width for
non-positive values and sets it to some default value (say, 80). So,
let's pass this default value directly to the function.
[kzak@redhat.com: - get_terminal_width() refactoring]
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
This adds a concise description of a tool to its usage text.
A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
|
|
Fixing plain typos, miswordings, inconsistent periods, some missing
angular brackets, and a proper pluralization (even when it involves
a constant, because for some languages the precise value matters).
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
|
|
Using angular brackets around each individual argument, indenting a
continuation line, not using a space before =, improving some wordings,
and the argument of --queue is a value (a piece of data), not a signal.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
|
|
The sigqueue(3) takes two values, signal and sigval. Contents of the
signal can be altered with --signal option argument, so the --queue
argument should be reserved to affect sigval_int.
This is regression fix introduced by commit
9e8dffd5cd29f03029b1ac99eecb129532ca5c0f.
Reference: http://man7.org/linux/man-pages/man3/sigqueue.3.html
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Also improve some option descriptions here and there.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
|
|
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Introduces by 2ab6683f59cd3371b1c3ac8b5c248d5104ed4d41.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Return 64 (aka SOME_OK) when more than process specified and the
operation success only for subset of the processes.
# kill -s 0 firefox mutt xxx; echo $?
kill: cannot find process "xxx"
64
We already use this concept for chcpu(8) or mount(8).
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Use of global variables is messy. The earlier implementation also
assumed queue argument never to be textual, such as 'HUP', which now
works as one might expect.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Long main() is difficult to read, so moving argument parsing to separate
function should make sense.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Getting usage as error message is not specific enough. As a user I want
to know what is wrong, and if it is unclear after error message how to
recover then I run command with --help.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
This should make it easier to understand how the program works.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Enabling options by renaming command is both unexpected and undocumented.
This magic is now deprecated and with remark of removal of this
functionality in future.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
And change the function argument to be an output stream. Earlier the
--help option made kill exit with none-zero value, that is now corrected.
CC: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
This makes code more readable.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
The kill was deprecated at the time lot of other tools got style
unification. Now when deprecation is lifted it is time to get kill
cleaner. This commit does not modify code, only various spacing issues,
removal of unecessary braces, and such are dealt.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
The '=' is expected for optional arguments and required in procps version.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
* add -L, --table
References: http://www.freelists.org/post/procps/kill1-consolidation
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Reference: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/threads.h#n30
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
[kzak@redhad.com: - s/commandname/name/
- improve --all description
- add -h/--help]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
env.c:24:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]
su.c:81:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]
fstab.c:581:14: warning: redundant redeclaration of 'strsignal' [-Wredundant-decls]
kill.h:1:13: note: previous declaration of 'get_pids' was here
kill.c:152:13: warning: redundant redeclaration of 'get_pids' [-Wredundant-decls]
kill.c:142:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]
getopt.c:89:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]
agetty.c:536:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls]
agetty.c:537:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
script.c:161:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
wall.c:96:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
libmount.h:362:26: note: previous declaration of 'mnt_update_get_fs' was here
libmount.h:454:26: note: previous declaration of 'mnt_context_get_fs' was here
mountP.h:383:26: warning: redundant redeclaration of 'mnt_context_get_fs' [-Wredundant-decls]
mountP.h:398:26: warning: redundant redeclaration of 'mnt_update_get_fs' [-Wredundant-decls]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Noticed on klibc building.
Signed-off-by: maximilian attems <max@stro.at>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Newly supported syntax for RT signals:
RT<n> = SIGRTMIN + n
RTMIN+<n> = SIGRTMIN + n
RTMAX-<n> = SIGRTMAX - n
the final signal number has to be in interval [SIGRTMIN,SIGRTMAX].
Note that the "SIG" prefix is also supported for RT signals of course.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=676297
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
We have PACKAGE_STRING in config.h that includes package name and
version. It's better to use this macro that hardcoded strings.
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|