]> git.ipfire.org Git - thirdparty/util-linux.git/commit
renice: support posix-compliant -n (via POSIXLY_CORRECT) and add --relative flag
authorDavid Anes <david.anes@suse.com>
Tue, 13 Dec 2022 10:02:36 +0000 (11:02 +0100)
committerDavid Anes <david.anes@suse.com>
Wed, 14 Dec 2022 12:38:24 +0000 (13:38 +0100)
commit56ce8f610367c6fb5847060b39a06ecfcbf0f0ca
treea0204e289113dd4c7850d6921d23067564e4ed94
parent5099e004b486e7c4f7153abc9843f49c1593fe66
renice: support posix-compliant -n (via POSIXLY_CORRECT) and add --relative flag

As noted in bug #1892, renice is not 100% posix compliant
as the '-n' option should update the priority 'relative'
to the current priority.

As such change would break compatibility, the current
approach was taken:
- donice() has now a new param to denote if priority is
  absolute or relative.
- main() interprets '-n' as absolute if environment
  variable POSIXLY_CORRECT is **not set**. Otherwise,
  it uses a relative value, as POSIX mandates.
- The option '--priority' is left as it is: uses an
  absolute value.
- A new option '--relative' is added, should a user
  want a posix compatible variant without setting up
  an environment variable.
- manpage is updated to display all these changes.

After this patch:
- Calling renice with '-n 2' on a process with current
  priority '2' and POSIXLY_CORRECT, will try to update
  it to priority '4', instead of '2'.
- Calling renice with '--priority 2' on a process with
  current priority '2', leaves the process at priority
  '2'.
- Calling renice with '--relative 2' on a process with
  current priority '2' will try to update the it to
  priority '4', regardless of environment flags.
sys-utils/renice.1.adoc
sys-utils/renice.c