Skip to content

nice: implement it - #251

Open
metif12 wants to merge 1 commit into
vlang:mainfrom
metif12:nice-implementation
Open

metif12 wants to merge 1 commit into
vlang:mainfrom
metif12:nice-implementation

Conversation

@metif12

@metif12 metif12 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

nice runs a command with an adjusted niceness.

The adjustment is parsed and validated but not applied, and that is the documented gap rather than a shortcut. There is no per-process niceness on Windows, and mapping it onto a priority class would silently give the caller something they did not ask for.

What the port delivers is the argument surface and the exit statuses, which are distinct from one another and which GNU really uses: 125 for nice's own failures, 126 for a command that cannot be run, 127 for one that cannot be found, and the command's own status otherwise. A bare non-option argument is the command, which is why nice 5 reports nice: ‘5’: No such file or directory and exits 127 rather than treating 5 as an adjustment.

While testing this I found an infinite loop. --adjustment=5 left the argument index unmoved, so parsing never returned — nice --adjustment=5 cmd would have hung forever at the prompt, not just in tests. test_parse_args_adjustment_spellings is the regression guard for it, and the reason it is worth a note here is that the hang looked identical to the machine contention I had been blaming for stalled builds. I nearly filed this as an environment problem.

Exit statuses were compared case by case against GNU 9.4 through WSL: bare invocation, bad adjustment, empty adjustment, adjustment with no command, missing command, and bare-number-as-command all match.

Runs a command with an adjusted niceness. The adjustment is parsed and validated but not applied, and that is the documented gap rather than a shortcut: there is no per-process niceness on Windows, and mapping it onto a priority class would silently give the caller something they did not ask for. What the port does deliver is the argument surface and the exit statuses, which are distinct from one another and which GNU really uses: 125 for nice's own failures, 126 for a command that cannot be run, 127 for one that cannot be found, and the command's own status otherwise. A bare non-option argument is the command, which is why 'nice 5' reports 'nice: 5: No such file or directory' and exits 127 rather than treating 5 as an adjustment. While testing this I found an infinite loop: --adjustment=5 left the argument index unmoved, so parsing it never returned. That was a real bug in user-facing code, not just a test failure, and test_parse_args_adjustment_spellings is the regression guard for it. Exit statuses were compared case by case against GNU 9.4 through WSL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant