diff options
author | Kevin Krakauer <krakauer@google.com> | 2018-09-12 15:22:24 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-09-12 15:23:35 -0700 |
commit | 2eff1fdd061be9cfabc36532dda8cbefeb02e534 (patch) | |
tree | 009e2a9cbca191a2d2a471b30380888cd50c0b4a /runsc/sandbox | |
parent | 0efde2bfbde2fea78134a32f5fb34332ec0ce531 (diff) |
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
Diffstat (limited to 'runsc/sandbox')
-rw-r--r-- | runsc/sandbox/sandbox.go | 19 |
1 files changed, 7 insertions, 12 deletions
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. |