Fix container pid.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-11-27 15:29:44 -08:00
parent 3a31ce267d
commit a6b6097c90
5 changed files with 54 additions and 20 deletions

View File

@@ -66,7 +66,7 @@ type Init struct {
pausing *atomicBool
status int
exited time.Time
pid safePid
pid int
closers []io.Closer
stdin io.Closer
stdio stdio.Stdio
@@ -116,8 +116,6 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) error {
pio *processIO
pidFile = newPidFile(p.Bundle)
)
p.pid.Lock()
defer p.pid.Unlock()
if r.Terminal {
if socket, err = runc.NewTempConsoleSocket(); err != nil {
@@ -173,7 +171,7 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) error {
if err != nil {
return errors.Wrap(err, "failed to retrieve OCI runtime container pid")
}
p.pid.pid = pid
p.pid = pid
return nil
}
@@ -219,7 +217,7 @@ func (p *Init) ID() string {
// Pid of the process
func (p *Init) Pid() int {
return p.pid.get()
return p.pid
}
// ExitStatus of the process
@@ -275,7 +273,6 @@ func (p *Init) setExited(status int) {
p.exited = time.Now()
p.status = status
p.Platform.ShutdownConsole(context.Background(), p.console)
p.pid.set(StoppedPID)
close(p.waitBlock)
}