File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
12
12
13
13
"encoding/json"
14
14
15
+ "github.com/opencontainers/runc/libcontainer"
15
16
"github.com/opencontainers/runc/libcontainer/utils"
16
17
"github.com/urfave/cli"
17
18
)
@@ -130,10 +131,14 @@ func getContainers(context *cli.Context) ([]containerState, error) {
130
131
if err != nil {
131
132
return nil , err
132
133
}
134
+ pid := state .BaseState .InitProcessPid
135
+ if containerStatus == libcontainer .Stopped {
136
+ pid = 0
137
+ }
133
138
bundle , annotations := utils .Annotations (state .Config .Labels )
134
139
s = append (s , containerState {
135
140
ID : state .BaseState .ID ,
136
- InitProcessPid : state . BaseState . InitProcessPid ,
141
+ InitProcessPid : pid ,
137
142
Status : containerStatus .String (),
138
143
Bundle : bundle ,
139
144
Created : state .BaseState .Created ,
Original file line number Diff line number Diff line change 7
7
"os"
8
8
"time"
9
9
10
+ "github.com/opencontainers/runc/libcontainer"
10
11
"github.com/opencontainers/runc/libcontainer/utils"
11
12
"github.com/urfave/cli"
12
13
)
@@ -55,11 +56,15 @@ instance of a container.`,
55
56
if err != nil {
56
57
return err
57
58
}
59
+ pid := state .BaseState .InitProcessPid
60
+ if containerStatus == libcontainer .Stopped {
61
+ pid = 0
62
+ }
58
63
bundle , annotations := utils .Annotations (state .Config .Labels )
59
64
cs := cState {
60
65
Version : state .BaseState .Config .Version ,
61
66
ID : state .BaseState .ID ,
62
- InitProcessPid : state . BaseState . InitProcessPid ,
67
+ InitProcessPid : pid ,
63
68
Status : containerStatus .String (),
64
69
Bundle : bundle ,
65
70
Rootfs : state .BaseState .Config .Rootfs ,
You can’t perform that action at this time.
0 commit comments