]> git.ipfire.org Git - thirdparty/lxc.git/commit
lxc-attach: Fix lost return codes of spawned processes that are killed 4204/head
authorMohammed Ajmal Siddiqui <ajmalsiddiqui21@gmail.com>
Wed, 5 Oct 2022 06:50:58 +0000 (12:20 +0530)
committerMohammed Ajmal Siddiqui <ajmalsiddiqui21@gmail.com>
Wed, 5 Oct 2022 06:50:58 +0000 (12:20 +0530)
commit4ebca5a005afbc19c08f663e24d3e76518d12fa8
tree3b80cbd18ddd929a9e1b01696f24f53e2426b3f6
parentfb319ca7d85f6916cb5a88b8a68f5171a8b71ef7
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