From 16d37973ebc8f36ef613c0885879648cceaf1c45 Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Thu, 28 Jun 2018 14:55:46 -0700 Subject: runsc: Add the "wait" subcommand. Users can now call "runsc wait " 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 --- runsc/boot/controller.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'runsc/boot/controller.go') diff --git a/runsc/boot/controller.go b/runsc/boot/controller.go index 56829c605..ff75a382e 100644 --- a/runsc/boot/controller.go +++ b/runsc/boot/controller.go @@ -61,6 +61,10 @@ const ( // and return its ExitStatus. ContainerWait = "containerManager.Wait" + // ContainerWaitPID is used to wait on a process with a certain PID in + // the sandbox and return its ExitStatus. + ContainerWaitPID = "containerManager.WaitPID" + // NetworkCreateLinksAndRoutes is the URPC endpoint for creating links // and routes in a network stack. NetworkCreateLinksAndRoutes = "Network.CreateLinksAndRoutes" @@ -234,7 +238,22 @@ func (cm *containerManager) Resume(_, _ *struct{}) error { // Wait waits for the init process in the given container. func (cm *containerManager) Wait(cid *string, waitStatus *uint32) error { log.Debugf("containerManager.Wait") - return cm.l.wait(cid, waitStatus) + return cm.l.waitContainer(*cid, waitStatus) +} + +// WaitPIDArgs are arguments to the WaitPID method. +type WaitPIDArgs struct { + // PID is the PID in the container's PID namespace. + PID int32 + + // CID is the container ID. + CID string +} + +// WaitPID waits for the process with PID 'pid' in the sandbox. +func (cm *containerManager) WaitPID(args *WaitPIDArgs, waitStatus *uint32) error { + log.Debugf("containerManager.Wait") + return cm.l.waitPID(kernel.ThreadID(args.PID), args.CID, waitStatus) } // SignalArgs are arguments to the Signal method. -- cgit v1.2.3