diff options
author | Karel Zak | 2011-02-28 17:15:40 +0100 |
---|---|---|
committer | Karel Zak | 2011-02-28 17:15:40 +0100 |
commit | a1504d8bf5239c451c3f4e8ab95e312bb60be4e8 (patch) | |
tree | d56ee267d29109628a5826f03299b87c52999ee7 /misc-utils/kill.c | |
parent | kill: translate "-l <num>" to RT<n> (diff) | |
download | kernel-qcow2-util-linux-a1504d8bf5239c451c3f4e8ab95e312bb60be4e8.tar.gz kernel-qcow2-util-linux-a1504d8bf5239c451c3f4e8ab95e312bb60be4e8.tar.xz kernel-qcow2-util-linux-a1504d8bf5239c451c3f4e8ab95e312bb60be4e8.zip |
kill: add -q sigval to use sigqueue(2)
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/kill.c')
-rw-r--r-- | misc-utils/kill.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/misc-utils/kill.c b/misc-utils/kill.c index f2f4e3737..ab0fb6a98 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -53,6 +53,7 @@ #include "c.h" #include "kill.h" #include "nls.h" +#include "strutils.h" struct signv { char *name; @@ -152,6 +153,11 @@ extern int *get_pids (char *, int); static char *progname; +#ifdef HAVE_SIGQUEUE +static int use_sigval; +static union sigval sigdata; +#endif + int main (int argc, char *argv[]) { int errors, numsig, pid; @@ -231,6 +237,17 @@ int main (int argc, char *argv[]) } continue; } + if (! strcmp (arg, "-q")) { + if (argc < 2) + return usage (1); + argc--, argv++; + arg = *argv; +#ifdef HAVE_SIGQUEUE + sigdata.sival_int = strtol_or_err(arg, _("failed to parse sigval")); + use_sigval = 1; +#endif + continue; + } /* `arg' begins with a dash but is not a known option. so it's probably something like -HUP, or -1/-n try to deal with it. @@ -403,11 +420,20 @@ int usage (int status) int kill_verbose (char *procname, int pid, int sig) { + int rc; + if (sig < 0) { printf ("%d\n", pid); return 0; } - if (kill (pid, sig) < 0) { +#ifdef HAVE_SIGQUEUE + if (use_sigval) + rc = sigqueue(pid, sig, sigdata); + else +#endif + rc = kill (pid, sig); + + if (rc < 0) { fprintf (stderr, "%s ", progname); perror (procname); return 1; |