Skip to content

Commit 8f0cad5

Browse files
avagincrosbymichael
authored andcommitted
Don't fix the size of the ExternalDescriptors array
In a future we may want to have more external descriptors. Signed-off-by: Andrey Vagin <[email protected]>
1 parent 655f1ce commit 8f0cad5

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

container.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type State struct {
5151
Config configs.Config `json:"config"`
5252

5353
// Container's standard descriptors (std{in,out,err}), needed for checkpoint and restore
54-
ExternalDescriptors [3]string `json:"external_descriptors,omitempty"`
54+
ExternalDescriptors []string `json:"external_descriptors,omitempty"`
5555
}
5656

5757
// A libcontainer container object.

process_linux.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ type parentProcess interface {
3434

3535
signal(os.Signal) error
3636

37-
externalDescriptors() [3]string
37+
externalDescriptors() []string
3838

39-
setExternalDescriptors(fds [3]string)
39+
setExternalDescriptors(fds []string)
4040
}
4141

4242
type setnsProcess struct {
@@ -45,7 +45,7 @@ type setnsProcess struct {
4545
childPipe *os.File
4646
cgroupPaths map[string]string
4747
config *initConfig
48-
fds [3]string
48+
fds []string
4949
}
5050

5151
func (p *setnsProcess) startTime() (string, error) {
@@ -149,11 +149,11 @@ func (p *setnsProcess) pid() int {
149149
return p.cmd.Process.Pid
150150
}
151151

152-
func (p *setnsProcess) externalDescriptors() [3]string {
152+
func (p *setnsProcess) externalDescriptors() []string {
153153
return p.fds
154154
}
155155

156-
func (p *setnsProcess) setExternalDescriptors(newFds [3]string) {
156+
func (p *setnsProcess) setExternalDescriptors(newFds []string) {
157157
p.fds = newFds
158158
}
159159

@@ -164,14 +164,14 @@ type initProcess struct {
164164
config *initConfig
165165
manager cgroups.Manager
166166
container *linuxContainer
167-
fds [3]string
167+
fds []string
168168
}
169169

170170
func (p *initProcess) pid() int {
171171
return p.cmd.Process.Pid
172172
}
173173

174-
func (p *initProcess) externalDescriptors() [3]string {
174+
func (p *initProcess) externalDescriptors() []string {
175175
return p.fds
176176
}
177177

@@ -281,12 +281,14 @@ func (p *initProcess) signal(sig os.Signal) error {
281281
return syscall.Kill(p.cmd.Process.Pid, s)
282282
}
283283

284-
func (p *initProcess) setExternalDescriptors(newFds [3]string) {
284+
func (p *initProcess) setExternalDescriptors(newFds []string) {
285285
p.fds = newFds
286286
}
287287

288-
func getPipeFds(pid int) ([3]string, error) {
289-
var fds [3]string;
288+
func getPipeFds(pid int) ([]string, error) {
289+
var fds []string
290+
291+
fds = make([]string, 3)
290292

291293
dirPath := filepath.Join("/proc", strconv.Itoa(pid), "/fd")
292294
for i := 0; i < 3; i++ {

restored_process.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/docker/libcontainer/system"
1010
)
1111

12-
func newRestoredProcess(pid int, fds [3]string) (*restoredProcess, error) {
12+
func newRestoredProcess(pid int, fds []string) (*restoredProcess, error) {
1313
var (
1414
err error
1515
)
@@ -31,7 +31,7 @@ func newRestoredProcess(pid int, fds [3]string) (*restoredProcess, error) {
3131
type restoredProcess struct {
3232
proc *os.Process
3333
processStartTime string
34-
fds [3]string
34+
fds []string
3535
}
3636

3737
func (p *restoredProcess) start() error {
@@ -68,11 +68,11 @@ func (p *restoredProcess) signal(s os.Signal) error {
6868
return p.proc.Signal(s)
6969
}
7070

71-
func (p *restoredProcess) externalDescriptors() [3]string {
71+
func (p *restoredProcess) externalDescriptors() []string {
7272
return p.fds
7373
}
7474

75-
func (p *restoredProcess) setExternalDescriptors(newFds [3]string) {
75+
func (p *restoredProcess) setExternalDescriptors(newFds []string) {
7676
p.fds = newFds
7777
}
7878

@@ -82,7 +82,7 @@ func (p *restoredProcess) setExternalDescriptors(newFds [3]string) {
8282
type nonChildProcess struct {
8383
processPid int
8484
processStartTime string
85-
fds [3]string
85+
fds []string
8686
}
8787

8888
func (p *nonChildProcess) start() error {
@@ -109,10 +109,10 @@ func (p *nonChildProcess) signal(s os.Signal) error {
109109
return newGenericError(fmt.Errorf("restored process cannot be signaled"), SystemError)
110110
}
111111

112-
func (p *nonChildProcess) externalDescriptors() [3]string {
112+
func (p *nonChildProcess) externalDescriptors() []string {
113113
return p.fds
114114
}
115115

116-
func (p *nonChildProcess) setExternalDescriptors(newFds [3]string) {
116+
func (p *nonChildProcess) setExternalDescriptors(newFds []string) {
117117
p.fds = newFds
118118
}

0 commit comments

Comments
 (0)