]> git.ipfire.org Git - thirdparty/lxc.git/commit
lxc-attach: Fix lost return codes of spawned processes that are killed
authorMohammed Ajmal Siddiqui <ajmalsiddiqui21@gmail.com>
Wed, 5 Oct 2022 06:50:58 +0000 (12:20 +0530)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 16 Dec 2022 16:35:05 +0000 (11:35 -0500)
commit011faff362e0e7c1c86121937f284ac8c64aba9f
treef06c1a3eda5dabbe9d2d695bb74dded04a5865ee
parent9316939459ba167299960fb28d1e9477736fc79b
lxc-attach: Fix lost return codes of spawned processes that are killed

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>
src/lxc/tools/lxc_attach.c