fix(sdk): add capture_exit_code option to nohup mode#686
Open
Issac-Newton wants to merge 1 commit intoalibaba:masterfrom
Open
fix(sdk): add capture_exit_code option to nohup mode#686Issac-Newton wants to merge 1 commit intoalibaba:masterfrom
Issac-Newton wants to merge 1 commit intoalibaba:masterfrom
Conversation
…ohup mode Previously arun() in nohup mode always returned exit_code=0 on success regardless of whether the underlying command failed (e.g. command not found → 127). Add capture_exit_code: bool = False to arun(). When True, the nohup command is wrapped in a subshell that writes cmd's exit code to a .rc file; handle_nohup_output reads it after process completion. Default False preserves existing behavior. Also add spec docs under docs/_specs/nohup-exit-code/ and update the integration test to assert exit_code == 127 for a non-existent command. Closes alibaba#685 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
capture_exit_code: bool = Falseparameter toSandbox.arun()— whenTrueandmode="nohup", wraps the command in a subshell that captures the real exit code into a.rcfilestart_nohup_processgenerates subshell command whenexit_code_fileis set;handle_nohup_outputreads the.rcfile after process completiontest_arun_nohup_nonexistent_command_exit_codeto assertexit_code == 127docs/_specs/nohup-exit-code/Test plan
tests/unit/sdk/test_arun_nohup.py)tests/integration/sdk/sandbox/test_sdk_client.py -m need_admin)capture_exit_code=False(default) — existing behavior unchangedcapture_exit_code=True+ non-existent command →exit_code=127fixes #685
🤖 Generated with Claude Code