From: Benno Schulenberg Date: Thu, 3 Jul 2025 14:47:50 +0000 (+0200) Subject: chrt: do not try to interpret the --pid option itself as a PID X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=624d2d37a201ec74d4c597a4c5886600aa2566be;p=thirdparty%2Futil-linux.git chrt: do not try to interpret the --pid option itself as a PID When not specifying a PID with --pid, `chrt` would report: chrt: invalid PID argument: '--pid' That was silly. After this change, `chrt --pid` will report: chrt: too few arguments Signed-off-by: Benno Schulenberg --- diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 415a9aa77..a72c0de26 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -474,6 +474,8 @@ int main(int argc, char **argv) policy_given = true; break; case 'p': + if (argc - optind == 0) + errx(EXIT_FAILURE, _("too few arguments")); errno = 0; /* strtopid_or_err() is not suitable here; 0 can be passed.*/ ctl->pid = strtos32_or_err(argv[argc - 1], _("invalid PID argument"));