Skip to content

winx4-proc process/environment control family (env #1352/#1353, timeout #1350, nice #1359) - #1394

Merged
caomengxuan666 merged 7 commits into
mainfrom
fix/winx4-proc
Oct 27, 2026
Merged

caomengxuan666 merged 7 commits into
mainfrom
fix/winx4-proc

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Process/environment control family fixes for env, timeout, and nice — one commit per issue on fix/winx4-proc (base a104bb28):

Verification (mingw + Wine harness, 2026-10-26)

Local harness build landed: configure OK, [97/97] Linking CXX executable mini.exe, build rc=0. Expectations are GNU coreutils 9.4 oracle values measured natively; full evidence is in the cluster REPORT (workspace record).

repro.sh (24 gating cases): PASS=18, FAIL=6 — all six failures adjudicated as non-product issues with evidence:

Side finding (report-only): stdbuf shows the same missing stop-options policy shape as #1353 (stdbuf -o0 ./echo -n hi → stdbuf: invalid option -- 'n'); chroot was not behaviorally probed in this harness round.

Still owed at integration: repo ctest/differential suites (need the full product build), the format pass, and the i18n catalog key for the new #1359 warning (the message currently uses the command's established plain-text diagnostic shape). Local [local-build] harness shims (GCC template-disambiguator fixes, working tree only) are not part of this PR.

Fixes #1350
Fixes #1352
Fixes #1353
Fixes #1359

…ck (#1352)

env's environment materialization used std::map throughout, so both the printed listing and the child environment block came out in alphabetical order instead of the inherited order with command-line assignments appended in the order given (GNU coreutils 9.4 oracle: 'env -i Z=1 A=2 env' prints exactly Z=1 then A=2; duplicate assignments replace in place at the first position).

Replace the map with an ordered entry list (EnvEntries) across parse_env_block, read_env_file, materialize_environment, print_env and build_environment_block, with setenv-style replace-in-place/append and order-preserving unset.

Regression: unit tests in tests/unit/env/env_unit_test.cpp (child block exact contents+order via a nested env, listing order, duplicate override position, unset order) and differential cases 70/71.

Verification pending: the mingw+Wine harness build has not yet obtained the machine-wide build slot, so these changes are compile- and runtime-unverified. WIP.
…1353)

env had no entry in option_policy_for_command, so the shared parser permuted across the whole command line: a child option such as the -l in 'env ./ls -l' was parsed as an env option and the launch died with parse-error exit 125, and path-form commands with option-like arguments never ran. GNU env parses with a leading-'+' getopt (coreutils 9.4 oracle verified): option processing stops at the first non-option argument (an assignment or the command name); everything after belongs to the command, and a dash token in command position is the command to run ('env FOO=1 -i ...' -> 127, tries to run '-i').

Give env stop_options_after_positionals = 1, the same policy shape nohup/xargs/getopt already use.

Regression: unit tests (path-form command with child options, options after an assignment belong to the command, dash token after assignment is the command and reports 127) and differential case 72.

Verification pending: mingw+Wine harness build still awaiting the machine-wide build slot; compile- and runtime-unverified. WIP.
The timeout branch mapped every timeout kill to exit 124 (or 128+SIG under --preserve-status) regardless of the signal sent. GNU timeout's rule is signal-dependent (coreutils 9.4 oracle, measured): without --preserve-status the status is 124 for TERM/INT/HUP/ABRT but 128+SIGKILL = 137 when the command is killed by SIGKILL; --preserve-status reports 128+SIG for every signal (TERM 143, INT 130, KILL 137). The --kill-after escalation branch already stamped 128+9; the initial timeout branch now does the same for -s KILL.

Regression: unit tests (KILL 137, TERM 124, INT 124, preserve TERM 143, preserve KILL 137) and differential cases 73/74.

Verification pending: mingw+Wine harness build still awaiting the machine-wide build slot; compile- and runtime-unverified. WIP.
)

nice passed the priority class as a CreateProcessW creation flag and never checked the result, so a priority change that could not be applied (e.g. raising priority without the privilege) silently ran the command at the unchanged priority. GNU nice warns and continues (coreutils 9.4 oracle, measured unprivileged): 'nice: cannot set niceness: Permission denied' on stderr, the command still runs, and its exit status is propagated.

Create the child suspended, apply the class with SetPriorityClass, cross-check with GetPriorityClass for silent clamps, print the GNU-shaped warning on failure, and resume the child either way.

Regression: unit tests (unapplied raise produces either silence-when-applied or exactly the GNU warning line while the child's exit status 7 propagates; the permitted lowering direction stays silent). No differential case: the warning is permission-environment-dependent, so a byte-equality oracle case would be environment-fragile; the forcing environment is the cluster's Wine-unprivileged harness probe.

Verification pending: mingw+Wine harness build still awaiting the machine-wide build slot; compile- and runtime-unverified. WIP. i18n note: the new message currently uses the established plain-text diagnostic shape of this command's other messages; catalog key assignment follows at integration.
@caomengxuan666 caomengxuan666 changed the title WIP: winx4-proc process/environment control family (env #1352/#1353, timeout #1350, nice #1359) winx4-proc process/environment control family (env #1352/#1353, timeout #1350, nice #1359) Oct 26, 2026
caomengxuan666 and others added 2 commits October 27, 2026 11:46
Per the branch's own #1353 rule (verified GNU), option parsing stops at
the first non-option argument, so '-u DROP' after 'KEEP1=1' would be the
utility name (127). And GNU applies -u to the inherited block before
assignments, so 'DROP=2' later on the same line survives anyway. Inject
DROP through the inherited environment and assert survivor order
positionally.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

Verification landed (merge e3865b6 brings origin/main in cleanly; fixup f200a4b):

@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 27, 2026 03:58
# Conflicts:
#	tests/differential/regressions/index.tsv
#	tests/unit/env/env_unit_test.cpp
#	tests/unit/timeout/timeout_unit_test.cpp
@caomengxuan666
caomengxuan666 merged commit 7975351 into main Oct 27, 2026
3 of 4 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/winx4-proc branch October 27, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant