Skip to content

fix(command): preserve execNoRead child status#9

Open
SaveTheRbtz wants to merge 1 commit into
masterfrom
codex-command-execnoread-status
Open

fix(command): preserve execNoRead child status#9
SaveTheRbtz wants to merge 1 commit into
masterfrom
codex-command-execnoread-status

Conversation

@SaveTheRbtz

@SaveTheRbtz SaveTheRbtz commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Drain and discard execNoRead() output before closing the pipe and waiting for the child.
  • Decode child wait statuses through one helper instead of calling WEXITSTATUS on non-exited statuses.

Why

The TSAN build exposed this through the existing regression test:

  • command::execNoRead returns 127 when shell exec fails
  • observed failure: 0 == 127

execNoRead() used the same pipe-backed command path as exec(), 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-tsan
  • TSAN_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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread include/util/command.hpp
int pid;
auto fp = command::open(cmd, pid, "");
if (!fp) return {-1, ""};
command::discard(fp);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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