From 624d2d37a201ec74d4c597a4c5886600aa2566be Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 3 Jul 2025 16:47:50 +0200 Subject: [PATCH] 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 --- schedutils/chrt.c | 2 ++ 1 file changed, 2 insertions(+) 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")); -- 2.47.2