Add cio.Load for loading io set
This adds a `Load` Opt for cio to load a tasks io/fifos without attaching or starting the copy routines. It adds the load method in `ctr` by default so that fifos or other IO are removed from disk on delete methods inbetween command runs. It is not the default for all task loads for backwards compat. and a user may want to keep io around to reuse or if log files are used. Fixes #2421 Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -307,6 +307,12 @@ func (c *container) get(ctx context.Context) (containers.Container, error) {
|
||||
|
||||
// get the existing fifo paths from the task information stored by the daemon
|
||||
func attachExistingIO(response *tasks.GetResponse, ioAttach cio.Attach) (cio.IO, error) {
|
||||
fifoSet := loadFifos(response)
|
||||
return ioAttach(fifoSet)
|
||||
}
|
||||
|
||||
// loadFifos loads the containers fifos
|
||||
func loadFifos(response *tasks.GetResponse) *cio.FIFOSet {
|
||||
path := getFifoDir([]string{
|
||||
response.Process.Stdin,
|
||||
response.Process.Stdout,
|
||||
@@ -315,13 +321,12 @@ func attachExistingIO(response *tasks.GetResponse, ioAttach cio.Attach) (cio.IO,
|
||||
closer := func() error {
|
||||
return os.RemoveAll(path)
|
||||
}
|
||||
fifoSet := cio.NewFIFOSet(cio.Config{
|
||||
return cio.NewFIFOSet(cio.Config{
|
||||
Stdin: response.Process.Stdin,
|
||||
Stdout: response.Process.Stdout,
|
||||
Stderr: response.Process.Stderr,
|
||||
Terminal: response.Process.Terminal,
|
||||
}, closer)
|
||||
return ioAttach(fifoSet)
|
||||
}
|
||||
|
||||
// getFifoDir looks for any non-empty path for a stdio fifo
|
||||
|
Reference in New Issue
Block a user