]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
chrt: with more than one argument, interpret first argument as priority
authorBenno Schulenberg <bensberg@telfort.nl>
Thu, 3 Jul 2025 14:47:49 +0000 (16:47 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 7 Jul 2025 11:33:11 +0000 (13:33 +0200)
The first argument is a priority not only for `chrt --pid <prio> <pid>`
but also for `chrt <prio> <command> [<argument>...]`.

This fixes an oversight in recent commit e7a2d62434.

Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Tested-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
schedutils/chrt.c

index 550cefe4d5bc26b0dda7651cc5fca16694f6ab51..415a9aa77a7c72b5c2a20b4ab29d2e6112383d22 100644 (file)
@@ -530,7 +530,7 @@ int main(int argc, char **argv)
 
        errno = 0;
 
-       if (need_prio || argc - optind == 2)
+       if (need_prio || argc - optind > 1)
                ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
        else
                ctl->priority = 0;