Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxc-attach: Fix lost return codes of spawned processes that are killed #4204

Merged
merged 1 commit into from Oct 19, 2022

Conversation

ajmalsiddiqui
Copy link
Contributor

Closes #4203.

lxc-attach swallows the return codes of processes that are terminated via a signal, and by default exits with a return code of 0 (i.e. indicating success) even if the command it tried to execute was terminated.

This patch fixes it by explicitly checking if the process was terminated via a signal, and returning an appropriate exit code.

Note that we add 128 to the signal value to generate the exit code because by convention the exit code is 128 + signal number. e.g. if a process is killed via signal 9, then the error code is 9 + 128 = 137.

Signed-off-by: Mohammed Ajmal Siddiqui ajmalsiddiqui21@gmail.com

lxc-attach swallows the return codes of processes that are terminated
via a signal, and by default exits with a return code of 0 (i.e.
indicating success) even if the command it tried to execute was
terminated.

This patch fixes it by explicitly checking if the process was terminated
via a signal, and returning an appropriate exit code.

Note that we add 128 to the signal value to generate the exit code
because by convention the exit code is 128 + signal number. e.g. if a
process is killed via signal 9, then the error code is 9 + 128 = 137.

Signed-off-by: Mohammed Ajmal Siddiqui <ajmalsiddiqui21@gmail.com>
@lxc-jenkins
Copy link

This pull request didn't trigger Jenkins as its author isn't in the allow list.

An organization member must perform one of the following:

  • To have this branch tested by Jenkins, use the "ok to test" command.
  • To have a one time test done, use the "test this please" command.

Those commands are simple Github comments of the format: "jenkins: COMMAND"

@brauner brauner merged commit fbed9bb into lxc:master Oct 19, 2022
@brauner
Copy link
Member

brauner commented Oct 19, 2022

Thank you!

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.

lxc-attach exits successfully even if process spawned by it is killed via a signal
3 participants