Skip to content

fix(shellgen): avoid ETXTBSY when forking while writing scripts - #3037

Open
mikeland73 wants to merge 1 commit into
mainfrom
mikeland73/devbox-actions-failure
Open

mikeland73 wants to merge 1 commit into
mainfrom
mikeland73/devbox-actions-failure

Conversation

@mikeland73

Copy link
Copy Markdown
Collaborator

Summary

TestConcurrentRunScriptFiles (added in #3032) flaked on ubuntu CI with .cmd.sh: Text file busy (run). When one goroutine forks while another still has a script temp file open for writing, the child keeps that writable fd until it execs, and on Linux exec'ing the script in that window fails with ETXTBSY (golang/go#22315). writeScriptFileAtomic now writes the temp file in a new writeTempFile helper that holds syscall.ForkLock for reading while the file is open, so no fork can inherit the writable fd.

How was it tested?

On macOS, go test -race -count=20 -run TestConcurrentRunScriptFiles ./internal/devbox and go test ./internal/shellgen pass, and devbox run lint is clean. ETXTBSY doesn't happen on macOS, so the ubuntu CI job is the real check for this change.

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.

🤖 Generated with Claude Code

A goroutine that forks while another has a script temp file open for
writing leaves the writable fd in the child until it execs. On Linux,
exec'ing the script in that window fails with "Text file busy", which
made TestConcurrentRunScriptFiles flaky on ubuntu CI. Hold
syscall.ForkLock for reading while the temp file is open
(golang/go#22315).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant