This code only works for backends that directly spawn the child
via the Command. It will not work for the libvirt backend. So
we move this code into the individual backends that need it.
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"github.com/dotcloud/docker/pkg/mount" |
| 7 | 7 |
"os" |
| 8 | 8 |
"os/exec" |
| 9 |
+ "syscall" |
|
| 9 | 10 |
) |
| 10 | 11 |
|
| 11 | 12 |
const ( |
| ... | ... |
@@ -67,7 +68,16 @@ func (d *driver) Run(c *execdriver.Command, startCallback execdriver.StartCallba |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 | 69 |
err = c.Wait() |
| 70 |
- return c.GetExitCode(), err |
|
| 70 |
+ return getExitCode(c), err |
|
| 71 |
+} |
|
| 72 |
+ |
|
| 73 |
+/// Return the exit code of the process |
|
| 74 |
+// if the process has not exited -1 will be returned |
|
| 75 |
+func getExitCode(c *execdriver.Command) int {
|
|
| 76 |
+ if c.ProcessState == nil {
|
|
| 77 |
+ return -1 |
|
| 78 |
+ } |
|
| 79 |
+ return c.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() |
|
| 71 | 80 |
} |
| 72 | 81 |
|
| 73 | 82 |
func (d *driver) Kill(p *execdriver.Command, sig int) error {
|
| ... | ... |
@@ -3,7 +3,6 @@ package execdriver |
| 3 | 3 |
import ( |
| 4 | 4 |
"errors" |
| 5 | 5 |
"os/exec" |
| 6 |
- "syscall" |
|
| 7 | 6 |
) |
| 8 | 7 |
|
| 9 | 8 |
var ( |
| ... | ... |
@@ -109,12 +108,3 @@ func (c *Command) Pid() int {
|
| 109 | 109 |
} |
| 110 | 110 |
return c.Process.Pid |
| 111 | 111 |
} |
| 112 |
- |
|
| 113 |
-// Return the exit code of the process |
|
| 114 |
-// if the process has not exited -1 will be returned |
|
| 115 |
-func (c *Command) GetExitCode() int {
|
|
| 116 |
- if c.ProcessState == nil {
|
|
| 117 |
- return -1 |
|
| 118 |
- } |
|
| 119 |
- return c.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() |
|
| 120 |
-} |
| ... | ... |
@@ -169,7 +169,16 @@ func (d *driver) Run(c *execdriver.Command, startCallback execdriver.StartCallba |
| 169 | 169 |
|
| 170 | 170 |
<-waitLock |
| 171 | 171 |
|
| 172 |
- return c.GetExitCode(), waitErr |
|
| 172 |
+ return getExitCode(c), waitErr |
|
| 173 |
+} |
|
| 174 |
+ |
|
| 175 |
+/// Return the exit code of the process |
|
| 176 |
+// if the process has not exited -1 will be returned |
|
| 177 |
+func getExitCode(c *execdriver.Command) int {
|
|
| 178 |
+ if c.ProcessState == nil {
|
|
| 179 |
+ return -1 |
|
| 180 |
+ } |
|
| 181 |
+ return c.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() |
|
| 173 | 182 |
} |
| 174 | 183 |
|
| 175 | 184 |
func (d *driver) Kill(c *execdriver.Command, sig int) error {
|