containerd / go-runc

runc bindings for Go
Apache License 2.0
161 stars 71 forks source link

Expose --preserve-fds option added in opencontainers/runc#1320 #8

Closed ijc closed 7 years ago

ijc commented 7 years ago

Signed-off-by: Ian Campbell ian.campbell@docker.com

crosbymichael commented 7 years ago

Maybe we should have a better API for this in the lib.

opts := &CreateOpts{}

opts.AddFile(f)
opts.AddFile(f)

runc.Create(..., opts)

This way we can provide a better UX for people wanting to add to the ExtraFiles and not assume that they are matched with the same fd of the calling process.

crosbymichael commented 7 years ago

Either an add file method or just add ExtraFiles []*os.File to the create opts and we can populate the preserve flag based on the len of that slice.

ijc commented 7 years ago

Adding ExtraFiles []*os.File to CreateOpts was my first (unpublished) cut. It potentially pushes the for loop which populates the cmd.ExtraFiles to the caller (it becomes a simple assignment here), but for others they will already have them all in their hand already (and with meaningful names) so this does sound more convenient overall. I'll make that change.

crosbymichael commented 7 years ago

It's beautiful