Skip to content

test(services): run bash -c directly in process tests to avoid ETXTBSY (#1351) - #1357

Closed
avantikonde wants to merge 1 commit into
rewrite/mainfrom
fix/1351-process-shim-race
Closed

avantikonde wants to merge 1 commit into
rewrite/mainfrom
fix/1351-process-shim-race

Conversation

@avantikonde

Copy link
Copy Markdown
Collaborator

Description

Replaces the temporary executable script shims in crates/nostream-services/src/process.rs (a_slow_child_times_out and run_answers_the_child_exit_code_and_capture_answers_its_output) with direct /bin/bash -c invocations, eliminating the parallel fork()/O_WRONLY ETXTBSY race without adding retries or serializing tests.

Related Issue

Closes #1351

Motivation and Context

Under parallel test execution (--test-threads=8), another test's Command::spawn (fork()) could inherit the writable file descriptor opened by shim()'s std::fs::write before close() completed and hold i_writecount > 0 on that inode until the other child execve'd, causing ETXTBSY ("Text file busy") when run_answers_the_child_exit_code_and_capture_answers_its_output spawned env-check. (Because std::fs::rename preserves the inode on the same filesystem, staging via a temp file + rename would still leave that same fork() window open on the inode.)

Invoking /bin/bash -c directly (using exec sleep 30 in a_slow_child_times_out so kill_on_drop kills sleep directly) tests the exact same run / capture env, argument, exit-code, stdout, and timeout behavior while never opening any executed binary for writing.

How Has This Been Tested?

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@changeset-bot

changeset-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4deb9e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0c236967-5453-4fcc-90ad-279bd57455e2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Low impact] The PR appears safe to merge.

Summary

Replaces temporary executable scripts in the process tests with direct /bin/bash -c calls.

  • Process tests run shell commands directly without writing scripts.

Reviews (1) · Last reviewed commit: "test(services): run bash -c directly in ..." · Reviewed by Greptile

@chappie-daemon

Copy link
Copy Markdown
Collaborator

Thank you for this — you diagnosed the race from the failure alone and shipped a fix faster than the issue had been open.

@cameri has chosen to keep the atomic-write approach instead: #1358 stages the shim in a temp file and renames it into place, keeping the helper rather than replacing it with /bin/bash -c. Your diff is the one that named the mechanism, and it is referenced there.

Closing this as superseded rather than leaving it to rot. If the race ever comes back through the narrow fork/exec window, the bash -c form in this branch is the fallback the #1358 description points at.

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.

2 participants