chrt: Allow optional priority for non‑prio policies without --pid
This extends commit e7a2d62434c2
("chrt: Make priority optional for policies that don't use it")
so that priority arguments are optional even when --pid is not specified.
Before this patch:
$ chrt --other ls -lh
chrt: invalid priority argument: 'ls'
-> only "chrt --other 0 ls -lh" would work
After this patch:
$ chrt --other ls -lh
$ chrt --other 0 ls -lh
-> both now work
If an out‑of‑range priority is given, it reports an error:
$ chrt --other 1 ls -lh
unsupported priority value for the policy: 1 (see --max for valid range)
Changes in v2:
- Removed is_number() and used isdigit_string() (Karel Zak)
- used _() for translation (Karel Zak)
Fixes: e7a2d62434c2 ("chrt: Make priority optional for policies that don't use it") Signed-off-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
tests/helpers/test_sigstate.c: explicitly reset SIGINT to default action after trapping
After upgrading bash to 5.3 to contain commit [1], if SIGINT was trapped in
asynchronous subshell, bash called set_signal_async_ignored to make sure
processes that are created by this asynchronous subshell to ignore SIGINT.
And it caused test case `kill/decode' failed, the signal INT was existed in
both of Blocked and Ignored
Seppo Takalo [Thu, 24 Jul 2025 11:38:59 +0000 (14:38 +0300)]
ldattach: Allow changing the MTU for GSM0710 framing
Traditionally ldattach have hard coded MTU of 127 bytes
which differs from defaults proposed in 3GPP TS 27.010
which is 31 bytes when basic framing is used.
Add '-m <value>' parameter that is only GSM0710 specific
and already handled by the kernel. Use same value for both
MTU and MRU.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Karel Zak [Mon, 28 Jul 2025 09:51:43 +0000 (11:51 +0200)]
Merge branch 'PR/column-colors' of https://github.com/karelzak/util-linux-work
* 'PR/column-colors' of https://github.com/karelzak/util-linux-work:
column: add support for color scheme
libsmartcols: add function to set/get header colors
lib/strutils: add ul_optstr_get_value()
lib/color-names: Fix color name canonicalization
column: add --color[=<when>] to control colorization
column: add basic colors support
Karel Zak [Mon, 21 Jul 2025 06:16:25 +0000 (08:16 +0200)]
setpriv: Improve getgroups() Portability
setpriv(1) is Linux-only, and on Linux, getgroups() returns at least one group.
However, it's better to use more portable and generic code patterns and assume
that getgroups() can return zero.
Fixes: https://github.com/util-linux/util-linux/issues/3654 Reported-by: Alejandro Colomar <alx@kernel.org> Signed-off-by: Karel Zak <kzak@redhat.com>
column: call gettext() on an error message only when it gets printed
Just mark error messages for translation, with gettext_noop(), and pass
them untranslated to the subroutines. Then call gettext() on such a
message only when an error occurs and the message gets printed.
The ranges are constructed greedily; in general it is difficult to
construct a minimal list.
% ./taskset -c 0-63:3,0-63:4 ./taskset -pc 0
pid 3926213's current affinity list: 0,3,4-8:2,9-15:3,16-20:2,21-27:3,28-32:2,33-39:3,40-44:2,45
chrt: do not try to interpret any other option as a PID either
When doing, for example, `chrt --pid --max`, it would report:
chrt: invalid PID argument: '--max'
This mistakenly gave the impression that the PID argument has to follow
directly after the --pid option.
Avoid this by delaying the parsing of a PID until after all options have
been parsed. Temporarily set 'ctl->pid' to zero to indicate that a PID
needs to be read.
After this change, `chrt --pid --max` will simply report the minimum and
maximum valid priorities. And `chrt --pid -v`:
chrt: too few arguments
Also, add a missing call of gettext() for the other error message.
chrt: simplify the other check for too few arguments
Without option --pid, always at least two arguments are needed:
the <priority> value and a <command>. (The 'need_prio' variable
is relevant only for the --pid case.)
Jesse Rosenstock [Fri, 27 Jun 2025 07:47:35 +0000 (09:47 +0200)]
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.
bash-completion: fix function name of enosys completion
The function "_enosys_module" referenced by the completion setting on
the last line of "bash-completion/enosys" is not defined in the
current master. As reported in Ref. [1], this causes the following
error on an attempt at argument completion for the "enosys" command:
Also, the function "_waitpid_module" defined in
"bash-completion/enosys" overwrites another completion function of the
same name defined in "bash-completion/waitpid". This patch renames
the function in "bash-completion/enosys" to the correct one,
"_enosys_module".
Karel Zak [Tue, 1 Jul 2025 07:57:25 +0000 (09:57 +0200)]
Merge branch 'PR/Benno-27Jun' of https://github.com/karelzak/util-linux-work
* 'PR/Benno-27Jun' of https://github.com/karelzak/util-linux-work:
lsclocks: (man) remove stray backslash, and correct short form of --time
script: (man,usage) correct the markup of the synopsis
chrt: (man) mark "argument" as optional, and unabbreviate it in usage
chrt: (man) correct the short form of --ext, from -d to -e
Karel Zak [Tue, 1 Jul 2025 07:56:22 +0000 (09:56 +0200)]
Merge branch 'PR/strv-prefix' of https://github.com/karelzak/util-linux-work
* 'PR/strv-prefix' of https://github.com/karelzak/util-linux-work:
lib/strutils: add ul_ prefix to strrep() and strrem() functions
lib/strutils: add ul_ prefix to split() function
lib/strutils: add ul_ prefix to strappend() functions
lib/strutils: add ul_ prefix to strconcat() functions
lib/strutils: add ul_ prefix to startswith() and endswith()
lib/strv: use ul_ prefix for strv functions
Karel Zak [Mon, 30 Jun 2025 10:20:13 +0000 (12:20 +0200)]
more: temporarily ignore stdin when waiting for stderr
more waits for user commands on stderr, but at the same time, it
monitors sigalfd and stdin (for data and POLLHUP|POLLNVAL). We need to
temporarily ignore stdin if there is new data waiting for read()
(e.g., dmesg | more); otherwise, more_key_command() will end in a busy
loop.
Fixes: https://github.com/util-linux/util-linux/issues/3634 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 24 Jun 2025 09:08:36 +0000 (11:08 +0200)]
Merge branch 'PR/chrt-optional-prio' of https://github.com/karelzak/util-linux-work
* 'PR/chrt-optional-prio' of https://github.com/karelzak/util-linux-work:
chrt: Make priority optional for policies that don't use it
chrt: Only display current settings when no policy is specified
chrt: Make minor cleanups in chrt
chrt: Make priority optional for policies that don't use it
Currently, chrt requires a priority argument even for scheduling
policies like SCHED_OTHER and SCHED_BATCH, which ignore it.
This change relaxes that requirement. Now, priority is only expected
for SCHED_FIFO and SCHED_RR. For other policies, a default value of 0
is set internally and no argument is required on the command line.
This simplifies usage when modifying runtime parameters like
--sched-runtime for non-realtime tasks.
For example, to change the EEVDF tunable base_slice, one currently
needs to run:
chrt -o -T 1000000 --pid 0 $PID
Passing '0' after --pid is not intutive and not required as priority
is not applicable to SCHED_OTHER tasks. Now with this patch, one can do:
chrt -o -T 1000000 --pid $PID
Passing '0' still works ensuring ABI doesn't break.
chrt: Only display current settings when no policy is specified
Previously, running "chrt --pid <pid>" with no policy options
would display the process’s current scheduling attributes, but
specifying a policy without a priority (e.g. chrt --rr --pid <pid>)
would silently fallback to displaying the same info. This was
confusing, since a policy option normally implies an intent to
change something.
This patch changes the behavior so that
chrt --pid <pid> continues to show the current settings:
chrt --pid 10862
pid 10862's current scheduling policy: SCHED_OTHER
pid 10862's current scheduling priority: 0
pid 10862's current runtime parameter: 2800000
If a policy is specified but no priority follows, chrt now
errors out:
Minor changes such as fixing an incorrect comment and aligning
the closing brace of an if condition in main() were made, along
with making the usage of --pid consistent across files instead
of -p, although -p still works, for better readability.
Karel Zak [Thu, 19 Jun 2025 08:45:14 +0000 (10:45 +0200)]
Merge branch 'ntfs3-type-detection' of https://github.com/js731ca/util-linux
* 'ntfs3-type-detection' of https://github.com/js731ca/util-linux:
bash-completion: update autocompletion list to 'ntfs3'
docs: update mount type to 'ntfs3'
tests: update expected type to 'ntfs3'
libblkid/libmount: ntfs: return filesystem type 'ntfs3'
libblkid/libmount: ntfs: return filesystem type 'ntfs3'
Change the returned filesystem type from 'ntfs' to 'ntfs3', to match
what the kernel/fs/ntfs3 driver calls register_filesystem on [1][2].
This same driver also registers itself as 'ntfs', but then runs in a
"legacy" mode [3] which forces the mount to stay RO.
Karel Zak [Mon, 9 Jun 2025 12:42:46 +0000 (14:42 +0200)]
Merge branch 'PR/Benno-2Jun' of https://github.com/karelzak/util-linux-work
* 'PR/Benno-2Jun' of https://github.com/karelzak/util-linux-work:
treewide: replace postal address in license specifier with a terse URL
docs: stop the copyright verbiage from getting included in the POT file
docs: make the "po4a:" line the first line, like in all other .adoc files
correct the full name of the GPL in various files
remove "Copyright (C) ...." notes from files that claim no copyright
remove two leftover license lines from colors.{c,h}
The documentation comment for scols_column_set_data_func was missing the
second asterisk in its opening marker, causing the contents to be
omitted from the rendered documentation.
Chen Qi [Wed, 4 Jun 2025 08:27:19 +0000 (16:27 +0800)]
ts/kill/decode: use RTMIN from 'kill -L' instead of hardcoding 34
glibc uses 34 as the value of SIGRTMIN:
https://sourceware.org/git/?p=glibc.git;a=blob;f=signal/allocrtsig.c;h=8ed8e37dd6c41f94be6eef042ce9db1af1153228;hb=HEAD#l27 """
static int current_rtmin = __SIGRTMIN + RESERVED_SIGRT; """
musl uses 35 as the value of SIGRTMIN:
https://git.musl-libc.org/cgit/musl/tree/src/signal/sigrtmin.c
With the hardcoded 34, test case fails with the following difference: