Fix: Parse exit code correctly for background commands (#3161)

* Parse exit code correctly for background commands

* Update ssh_box.py
This commit is contained in:
மனோஜ்குமார் பழனிச்சாமி 2024-07-29 21:27:58 +05:30 committed by GitHub
parent a52df6a272
commit 570fd6e483
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -128,7 +128,7 @@ class RuntimeClient:
self.shell.expect(self.__bash_expect_regex)
_exit_code_output = self.shell.before
logger.debug(f'Exit code Output: {_exit_code_output}')
exit_code = int(_exit_code_output.strip())
exit_code = int(_exit_code_output.strip().split()[0])
return output, exit_code
async def run_action(self, action) -> Observation:

View File

@ -444,7 +444,7 @@ class DockerSSHBox(Sandbox):
return self._send_interrupt(
cmd, command_output, ignore_last_output=True
)
cleaned_exit_code_str = exit_code_str.replace('echo $?', '').strip()
cleaned_exit_code_str = exit_code_str.replace('echo $?', '').strip().split()[0]
try:
exit_code = int(cleaned_exit_code_str)