diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-02-27 13:51:43 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-01 21:17:51 +0000 |
commit | 8b87a17f569010d694a124848d1489f8c1430516 (patch) | |
tree | 0b9a389f40f1ccbeb142635f84fadfdd66e4e5db /libpod/oci.go | |
parent | aea4f24919dcf5797f046465958c082ac3cba730 (diff) | |
download | podman-8b87a17f569010d694a124848d1489f8c1430516.tar.gz podman-8b87a17f569010d694a124848d1489f8c1430516.tar.bz2 podman-8b87a17f569010d694a124848d1489f8c1430516.zip |
Add tracking for exec session IDs
Exec sessions now have an ID generated and assigned to their PID
and stored in the database state. This allows us to track what
exec sessions are currently active.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #412
Approved by: baude
Diffstat (limited to 'libpod/oci.go')
-rw-r--r-- | libpod/oci.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libpod/oci.go b/libpod/oci.go index 225643f39..f25c6bdb9 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -471,7 +471,15 @@ func (r *OCIRuntime) unpauseContainer(ctr *Container) error { // TODO: Add --detach support // TODO: Convert to use conmon // TODO: add --pid-file and use that to generate exec session tracking -func (r *OCIRuntime) execContainer(c *Container, cmd []string, tty bool, user string, capAdd, env []string) error { +func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty bool, user, sessionID string) (*exec.Cmd, error) { + if len(cmd) == 0 { + return nil, errors.Wrapf(ErrInvalidArg, "must provide a command to execute") + } + + if sessionID == "" { + return nil, errors.Wrapf(ErrEmptyID, "must provide a session ID for exec") + } + args := []string{} // TODO - should we maintain separate logpaths for exec sessions? @@ -481,6 +489,8 @@ func (r *OCIRuntime) execContainer(c *Container, cmd []string, tty bool, user st args = append(args, "--cwd", c.config.Spec.Process.Cwd) + args = append(args, "--pid-file", c.execPidPath(sessionID)) + if tty { args = append(args, "--tty") } @@ -512,9 +522,5 @@ func (r *OCIRuntime) execContainer(c *Container, cmd []string, tty bool, user st execCmd.Stderr = os.Stderr execCmd.Stdin = os.Stdin - if err := execCmd.Start(); err != nil { - return errors.Wrapf(err, "error starting exec command for container %s", c.ID()) - } - - return execCmd.Wait() + return execCmd, nil } |