From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id E9CFB3857BB3; Wed, 15 Mar 2023 21:10:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9CFB3857BB3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678914656; bh=hyZ2r/vEZWYUsf/tBoR8Kfi3EbW1dAx2OcUmoMlyEMI=; h=From:To:Subject:Date:From; b=iL8U98w+n1L4G2i2NhtGzzMsQJW2doWJeciY9vMyeHUF/K+dMZSzDDhWOxIs06SxG miU58lH5HJluXYwHEYuLrOb/2DUM8/2p23Zw0Qq3YaL+bH5TyRacHJ4nWoJMjW6zu1 Y+7rXBpxuDZAKUO/M+jAwl6VUFuWfigZMZeQdNBM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: kill(1): Align list options to latest Linux kill(1) X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 3dfb3217af2d1bc4be430675b6e591606aaa56fb X-Git-Newrev: 915c6eb0266bf1e1b2b1a1c0a1f075ef6c364537 Message-Id: <20230315211056.E9CFB3857BB3@sourceware.org> Date: Wed, 15 Mar 2023 21:10:56 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D915c6eb0266= bf1e1b2b1a1c0a1f075ef6c364537 commit 915c6eb0266bf1e1b2b1a1c0a1f075ef6c364537 Author: Corinna Vinschen AuthorDate: Wed Mar 15 21:59:04 2023 +0100 Commit: Corinna Vinschen CommitDate: Wed Mar 15 22:08:04 2023 +0100 Cygwin: kill(1): Align list options to latest Linux kill(1) =20 - Don't print all RT signals, just the allowed patterns - Add -L/--table option to print a table of signals with signal numbers =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/utils/kill.cc | 105 ++++++++++++++++++++++++++++++++++++++++++++---= ---- 1 file changed, 91 insertions(+), 14 deletions(-) diff --git a/winsup/utils/kill.cc b/winsup/utils/kill.cc index a430b353720b..fb45e4c9dcfa 100644 --- a/winsup/utils/kill.cc +++ b/winsup/utils/kill.cc @@ -26,24 +26,26 @@ static struct option longopts[] =3D {"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} }; =20 -static char opts[] =3D "hl::fs:WV"; +static char opts[] =3D "hl::fs:LWV"; =20 static void __attribute__ ((__noreturn__)) usage (FILE *where =3D 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) } =20 static void -listsig (const char *in_sig) +checksig (const char *in_sig) { - int sig; - if (!in_sig) - for (sig =3D 1; sig < NSIG - 1; sig++) - printf ("%s%c", strsigno (sig) + 3, (sig < NSIG - 1) ? ' ' : '\n'); + int sig =3D getsig (in_sig); + test_for_unknown_sig (sig, in_sig); + if (sig && atoi (in_sig) =3D=3D sig) + puts (strsigno (sig) + 3); else + printf ("%d\n", sig); + exit (0); +} + +static void +listsig () +{ + int chars =3D 0; + + for (int sig =3D 1; sig < SIGRTMIN; sig++) { - sig =3D getsig (in_sig); - test_for_unknown_sig (sig, in_sig); - if (sig && atoi (in_sig) =3D=3D sig) - puts (strsigno (sig) + 3); - else - printf ("%d\n", sig); + chars +=3D printf ("%s ", strsigno (sig) + 3); + if (chars > 72) + { + puts (""); + chars =3D 0; + } + switch (sig) + { + case SIGABRT: + chars +=3D printf ("%s ", "IOT"); + break; + case SIGCHLD: + chars +=3D printf ("%s ", "CLD"); + break; + case SIGIO: + chars +=3D printf ("%s ", "POLL"); + break; + case SIGPWR: + chars +=3D printf ("%s ", "LOST"); + break; + } + if (chars > 70) + { + puts (""); + chars =3D 0; + } + } + fputs ("RT RTMIN+ RTMAX-\n", stdout); + exit (0); +} + +static void +tablesig () +{ + int chars =3D 0; + + for (int sig =3D 1; sig < SIGRTMIN; sig++) + { + chars +=3D printf ("%2d %-7s ", sig, strsigno (sig) + 3); + if (chars > 70) + { + puts (""); + chars =3D 0; + } + switch (sig) + { + case SIGABRT: + chars +=3D printf ("%2d %-7s ", sig, "IOT"); + break; + case SIGCHLD: + chars +=3D printf ("%2d %-7s ", sig, "CLD"); + break; + case SIGIO: + chars +=3D printf ("%2d %-7s ", sig, "POLL"); + break; + case SIGPWR: + chars +=3D printf ("%2d %-7s ", sig, "LOST"); + break; + } + if (chars > 70) + { + puts (""); + chars =3D 0; + } } + fputs ("32 RTMIN 64 RTMAX\n", stdout); exit (0); } =20 @@ -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 =3D 1;