From 2eff1fdd061be9cfabc36532dda8cbefeb02e534 Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Wed, 12 Sep 2018 15:22:24 -0700 Subject: runsc: Add exec flag that specifies where to save the sandbox-internal pid. This is different from the existing -pid-file flag, which saves a host pid. PiperOrigin-RevId: 212713968 Change-Id: I2c486de8dd5cfd9b923fb0970165ef7c5fc597f0 --- runsc/sandbox/sandbox.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'runsc/sandbox') diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go index 195deda1e..8e90dcc70 100644 --- a/runsc/sandbox/sandbox.go +++ b/runsc/sandbox/sandbox.go @@ -187,8 +187,9 @@ func (s *Sandbox) Processes(cid string) ([]*control.Process, error) { return pl, nil } -// Execute runs the specified command in the container. -func (s *Sandbox) Execute(cid string, e *control.ExecArgs) (syscall.WaitStatus, error) { +// Execute runs the specified command in the container. It returns the pid of +// the newly created process. +func (s *Sandbox) Execute(cid string, args *control.ExecArgs) (int32, error) { log.Debugf("Executing new process in container %q in sandbox %q", cid, s.ID) conn, err := s.sandboxConnect() if err != nil { @@ -196,20 +197,14 @@ func (s *Sandbox) Execute(cid string, e *control.ExecArgs) (syscall.WaitStatus, } defer conn.Close() - ea := &boot.ExecArgs{ - ExecArgs: *e, - CID: cid, - } + rpcArgs := &boot.ExecArgs{ExecArgs: *args, CID: cid} // Send a message to the sandbox control server to start the container. - var waitStatus uint32 - // TODO: Pass in the container id (cid) here. The sandbox - // should execute in the context of that container. - if err := conn.Call(boot.ContainerExecute, ea, &waitStatus); err != nil { + var pid int32 + if err := conn.Call(boot.ContainerExecuteAsync, rpcArgs, &pid); err != nil { return 0, fmt.Errorf("error executing in sandbox: %v", err) } - - return syscall.WaitStatus(waitStatus), nil + return pid, nil } // Event retrieves stats about the sandbox such as memory and CPU utilization. -- cgit v1.2.3