diff options
author | Kevin Krakauer <krakauer@google.com> | 2018-06-28 14:55:46 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-06-28 14:56:36 -0700 |
commit | 16d37973ebc8f36ef613c0885879648cceaf1c45 (patch) | |
tree | c797f2c9352518b5372e961b74a6ae14f56fc307 /runsc/container/container.go | |
parent | 5a8e014c3d424abfe931b8493d06a129c3fdd388 (diff) |
runsc: Add the "wait" subcommand.
Users can now call "runsc wait <container id>" to wait on a particular process
inside the container. -pid can also be used to wait on a specific PID.
Manually tested the wait subcommand for a single waiter and multiple waiters
(simultaneously 2 processes waiting on the container and 2 processes waiting on
a PID within the container).
PiperOrigin-RevId: 202548978
Change-Id: Idd507c2cdea613c3a14879b51cfb0f7ea3fb3d4c
Diffstat (limited to 'runsc/container/container.go')
-rw-r--r-- | runsc/container/container.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/runsc/container/container.go b/runsc/container/container.go index b2ea78084..042c76577 100644 --- a/runsc/container/container.go +++ b/runsc/container/container.go @@ -353,6 +353,20 @@ func (c *Container) Wait() (syscall.WaitStatus, error) { return c.Sandbox.Wait(c.ID) } +// WaitRootPID waits for process 'pid' in the sandbox's PID namespace and +// returns its WaitStatus. +func (c *Container) WaitRootPID(pid int32) (syscall.WaitStatus, error) { + log.Debugf("Wait on pid %d in sandbox %q", pid, c.Sandbox.ID) + return c.Sandbox.WaitPID(pid, c.Sandbox.ID) +} + +// WaitPID waits for process 'pid' in the container's PID namespace and returns +// its WaitStatus. +func (c *Container) WaitPID(pid int32) (syscall.WaitStatus, error) { + log.Debugf("Wait on pid %d in container %q", pid, c.ID) + return c.Sandbox.WaitPID(pid, c.ID) +} + // Signal sends the signal to the container. func (c *Container) Signal(sig syscall.Signal) error { log.Debugf("Signal container %q", c.ID) |