Merge pull request #328 from icecrime/signal_exit_code

Fix exit codes when dying on a signal
This commit is contained in:
Mrunal Patel 2015-01-12 17:29:26 -08:00
commit 1d3b2589d7
1 changed files with 10 additions and 1 deletions

View File

@ -17,6 +17,10 @@ import (
"github.com/docker/libcontainer/system" "github.com/docker/libcontainer/system"
) )
const (
EXIT_SIGNAL_OFFSET = 128
)
// TODO(vishh): This is part of the libcontainer API and it does much more than just namespaces related work. // TODO(vishh): This is part of the libcontainer API and it does much more than just namespaces related work.
// Move this to libcontainer package. // Move this to libcontainer package.
// Exec performs setup outside of a namespace so that a container can be // Exec performs setup outside of a namespace so that a container can be
@ -113,7 +117,12 @@ func Exec(container *libcontainer.Config, stdin io.Reader, stdout, stderr io.Wri
if !container.Namespaces.Contains(libcontainer.NEWPID) { if !container.Namespaces.Contains(libcontainer.NEWPID) {
killAllPids(container) killAllPids(container)
} }
return command.ProcessState.Sys().(syscall.WaitStatus).ExitStatus(), nil
waitStatus := command.ProcessState.Sys().(syscall.WaitStatus)
if waitStatus.Signaled() {
return EXIT_SIGNAL_OFFSET + int(waitStatus.Signal()), nil
}
return waitStatus.ExitStatus(), nil
} }
// killAllPids itterates over all of the container's processes // killAllPids itterates over all of the container's processes