]> git.ipfire.org Git - thirdparty/util-linux.git/commit
taskset: Accept 0 pid for current process master
authorJesse Rosenstock <jmr@google.com>
Fri, 27 Jun 2025 07:47:35 +0000 (09:47 +0200)
committerJesse Rosenstock <jmr@google.com>
Wed, 2 Jul 2025 20:04:40 +0000 (22:04 +0200)
commit6c87a3ac5ee96194e0e461db24b1bbfe369bdb59
treebd86850612d0c841e15c58132ae37c5ba7660dbd
parent4581ede384f22983d6155768635ce43cb5304cb0
taskset: Accept 0 pid for current process

This is useful to print the current mask without using `$$`: `taskset -p 0`.

It is also helpful to test taskset: `taskset -c 1-4 taskset -p 0`.
This is not easy with `$$`.

sched_setaffinity(2)/sched_getaffinity(2) accept 0 for the calling
thread, so this seems consistent.

As an implementation detail, we replace 0 with getpid(), so the existing
pid != 0 <==> "will exec" logic continues to work unchanged.

A reasonable alternative would be to interpret just `taskset` (currently
an error) as printing the current mask.  This seems less orthogonal,
and a better use may be found for plain `taskset` in the future.

Signed-off-by: Jesse Rosenstock <jmr@google.com>
schedutils/taskset.1.adoc
schedutils/taskset.c