Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2023-03-15 23:59:04 +0300
committerCorinna Vinschen <corinna@vinschen.de>2023-03-16 00:08:04 +0300
commit915c6eb0266bf1e1b2b1a1c0a1f075ef6c364537 (patch)
treee96e3ad8c05c9a090827c504d5c0cf05011cbe9b /winsup/utils
parent3dfb3217af2d1bc4be430675b6e591606aaa56fb (diff)
Cygwin: kill(1): Align list options to latest Linux kill(1)
- Don't print all RT signals, just the allowed patterns - Add -L/--table option to print a table of signals with signal numbers Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/utils')
-rw-r--r--winsup/utils/kill.cc105
1 files changed, 91 insertions, 14 deletions
diff --git a/winsup/utils/kill.cc b/winsup/utils/kill.cc
index a430b3537..fb45e4c9d 100644
--- a/winsup/utils/kill.cc
+++ b/winsup/utils/kill.cc
@@ -26,24 +26,26 @@ static struct option longopts[] =
{"list", optional_argument, NULL, 'l'},
{"force", no_argument, NULL, 'f'},
{"signal", required_argument, NULL, 's'},
+ {"table", no_argument, NULL, 'L'},
{"winpid", no_argument, NULL, 'W'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
-static char opts[] = "hl::fs:WV";
+static char opts[] = "hl::fs:LWV";
static void __attribute__ ((__noreturn__))
usage (FILE *where = stderr)
{
fprintf (where , ""
"Usage: %1$s [-fW] [-signal] [-s signal] pid1 [pid2 ...]\n"
- " %1$s -l [signal]\n"
+ " %1$s -l [signal] | -L\n"
"\n"
"Send signals to processes\n"
"\n"
" -f, --force force, using win32 interface if necessary\n"
" -l, --list print a list of signal names\n"
+ " -L, --table print a formatted table of signal names\n"
" -s, --signal send signal (use %1$s --list for a list)\n"
" -W, --winpid specified pids are windows PIDs, not Cygwin PIDs\n"
" (use with extreme caution!)\n"
@@ -153,21 +155,90 @@ test_for_unknown_sig (int sig, const char *sigstr)
}
static void
-listsig (const char *in_sig)
+checksig (const char *in_sig)
{
- int sig;
- if (!in_sig)
- for (sig = 1; sig < NSIG - 1; sig++)
- printf ("%s%c", strsigno (sig) + 3, (sig < NSIG - 1) ? ' ' : '\n');
+ int sig = getsig (in_sig);
+ test_for_unknown_sig (sig, in_sig);
+ if (sig && atoi (in_sig) == sig)
+ puts (strsigno (sig) + 3);
else
+ printf ("%d\n", sig);
+ exit (0);
+}
+
+static void
+listsig ()
+{
+ int chars = 0;
+
+ for (int sig = 1; sig < SIGRTMIN; sig++)
{
- sig = getsig (in_sig);
- test_for_unknown_sig (sig, in_sig);
- if (sig && atoi (in_sig) == sig)
- puts (strsigno (sig) + 3);
- else
- printf ("%d\n", sig);
+ chars += printf ("%s ", strsigno (sig) + 3);
+ if (chars > 72)
+ {
+ puts ("");
+ chars = 0;
+ }
+ switch (sig)
+ {
+ case SIGABRT:
+ chars += printf ("%s ", "IOT");
+ break;
+ case SIGCHLD:
+ chars += printf ("%s ", "CLD");
+ break;
+ case SIGIO:
+ chars += printf ("%s ", "POLL");
+ break;
+ case SIGPWR:
+ chars += printf ("%s ", "LOST");
+ break;
+ }
+ if (chars > 70)
+ {
+ puts ("");
+ chars = 0;
+ }
+ }
+ fputs ("RT<N> RTMIN+<N> RTMAX-<N>\n", stdout);
+ exit (0);
+}
+
+static void
+tablesig ()
+{
+ int chars = 0;
+
+ for (int sig = 1; sig < SIGRTMIN; sig++)
+ {
+ chars += printf ("%2d %-7s ", sig, strsigno (sig) + 3);
+ if (chars > 70)
+ {
+ puts ("");
+ chars = 0;
+ }
+ switch (sig)
+ {
+ case SIGABRT:
+ chars += printf ("%2d %-7s ", sig, "IOT");
+ break;
+ case SIGCHLD:
+ chars += printf ("%2d %-7s ", sig, "CLD");
+ break;
+ case SIGIO:
+ chars += printf ("%2d %-7s ", sig, "POLL");
+ break;
+ case SIGPWR:
+ chars += printf ("%2d %-7s ", sig, "LOST");
+ break;
+ }
+ if (chars > 70)
+ {
+ puts ("");
+ chars = 0;
+ }
}
+ fputs ("32 RTMIN 64 RTMAX\n", stdout);
exit (0);
}
@@ -278,7 +349,13 @@ main (int argc, char **argv)
}
if (argv[optind])
usage ();
- listsig (optarg);
+ if (optarg)
+ checksig (optarg);
+ else
+ listsig ();
+ break;
+ case 'L':
+ tablesig ();
break;
case 'f':
force = 1;