Skip to content

Instantly share code, notes, and snippets.

@dqminh
Created January 11, 2015 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dqminh/526dfd72a60d2575cee4 to your computer and use it in GitHub Desktop.
Save dqminh/526dfd72a60d2575cee4 to your computer and use it in GitHub Desktop.
From e924b34feae782228a7b43286a1cc6f2614f0ae1 Mon Sep 17 00:00:00 2001
From: "Daniel, Dao Quang Minh" <dqminh89@gmail.com>
Date: Sun, 11 Jan 2015 04:07:57 -0500
Subject: [PATCH] the process is sigkilled, return correct exit code
Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
---
daemon/execdriver/native/driver.go | 3 ---
vendor/src/github.com/docker/libcontainer/namespaces/exec.go | 9 ++++++++-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go
index 76b7baf..5b324c5 100644
--- a/daemon/execdriver/native/driver.go
+++ b/daemon/execdriver/native/driver.go
@@ -162,9 +162,6 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
}
// wait for the container to exit.
execOutput := <-execOutputChan
- if oomKill {
- execOutput.exitCode = OOMExitCode
- }
return execdriver.ExitStatus{ExitCode: execOutput.exitCode, OOMKilled: oomKill}, execOutput.err
}
diff --git a/vendor/src/github.com/docker/libcontainer/namespaces/exec.go b/vendor/src/github.com/docker/libcontainer/namespaces/exec.go
index b7873ed..2ed0fc9 100644
--- a/vendor/src/github.com/docker/libcontainer/namespaces/exec.go
+++ b/vendor/src/github.com/docker/libcontainer/namespaces/exec.go
@@ -110,7 +110,14 @@ func Exec(container *libcontainer.Config, stdin io.Reader, stdout, stderr io.Wri
return -1, err
}
}
- return command.ProcessState.Sys().(syscall.WaitStatus).ExitStatus(), nil
+ waitStatus := command.ProcessState.Sys().(syscall.WaitStatus)
+ exitStatus := waitStatus.ExitStatus()
+ // if the process is killed, return 137
+ signal := waitStatus.Signal()
+ if signal == syscall.SIGKILL {
+ return 128 + int(syscall.SIGKILL), nil
+ }
+ return exitStatus, nil
}
// DefaultCreateCommand will return an exec.Cmd with the Cloneflags set to the proper namespaces
--
1.9.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment