fix(command): preserve execNoRead child status#9
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b41fc18cb4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| int pid; | ||
| auto fp = command::open(cmd, pid, ""); | ||
| if (!fp) return {-1, ""}; | ||
| command::discard(fp); |
There was a problem hiding this comment.
Avoid waiting on descendant stdout in execNoRead
When execNoRead runs a shell command that backgrounds a program, e.g. an on-click command like pavucontrol &, the shell can exit immediately but the background process still inherits the piped stdout fd created in open(). Draining here waits for EOF from every process holding that fd, so the caller never reaches close()/waitpid until the background app exits, which regresses no-read/fire-and-forget commands that previously returned after the shell child exited.
Useful? React with 👍 / 👎.
Summary
execNoRead()output before closing the pipe and waiting for the child.WEXITSTATUSon non-exited statuses.Why
The TSAN build exposed this through the existing regression test:
command::execNoRead returns 127 when shell exec fails0 == 127execNoRead()used the same pipe-backed command path asexec(), but closed the read end without consuming stdout. Draining the pipe keeps the child status path deterministic while still returning no output.Testing
ninja -C build-tsanTSAN_OPTIONS=suppressions=./tsan.supp:halt_on_error=1:abort_on_error=1:print_summary=1 ./build-tsan/test/utils/utils_test "command::execNoRead returns 127 when shell exec fails"TSAN_OPTIONS=suppressions=./tsan.supp:halt_on_error=1:abort_on_error=1:print_summary=1 meson test -C build-tsan --no-rebuild --print-errorlogs