mirror of
https://github.com/containers/podman.git
synced 2025-06-20 00:51:16 +08:00
implement the exitcode when start a container with attach
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
This commit is contained in:
@ -99,12 +99,17 @@ func start(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range responses {
|
for _, r := range responses {
|
||||||
if r.Err == nil && !startOptions.Attach {
|
if r.Err == nil {
|
||||||
fmt.Println(r.RawInput)
|
if startOptions.Attach {
|
||||||
|
// Implement the exitcode when the only one container is enabled attach
|
||||||
|
registry.SetExitCode(r.ExitCode)
|
||||||
|
} else {
|
||||||
|
fmt.Println(r.RawInput)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errs = append(errs, r.Err)
|
errs = append(errs, r.Err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO need to understand an implement exitcodes
|
|
||||||
return errs.PrintErrors()
|
return errs.PrintErrors()
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,18 @@ var _ = Describe("Podman start", func() {
|
|||||||
Expect(session.OutputToString()).To(Equal(name))
|
Expect(session.OutputToString()).To(Equal(name))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman start single container with attach and test the signal", func() {
|
||||||
|
SkipIfRemote()
|
||||||
|
session := podmanTest.Podman([]string{"create", "--entrypoint", "sh", ALPINE, "-c", "exit 1"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
cid := session.OutputToString()
|
||||||
|
session = podmanTest.Podman([]string{"start", "--attach", cid})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
// It should forward the signal
|
||||||
|
Expect(session.ExitCode()).To(Equal(1))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman start multiple containers", func() {
|
It("podman start multiple containers", func() {
|
||||||
session := podmanTest.Podman([]string{"create", "-d", "--name", "foobar99", ALPINE, "ls"})
|
session := podmanTest.Podman([]string{"create", "-d", "--name", "foobar99", ALPINE, "ls"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user