2021-08-23 09:14:53 -04:00
|
|
|
//go:build linux || freebsd
|
2017-11-01 19:37:53 -04:00
|
|
|
// +build linux freebsd
|
2016-11-14 13:53:53 -05:00
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package logger // import "github.com/docker/docker/daemon/logger"
|
2016-11-14 13:53:53 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io"
|
|
|
|
|
2017-09-22 09:52:41 -04:00
|
|
|
"github.com/containerd/fifo"
|
2016-11-14 13:53:53 -05:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
func openPluginStream(a *pluginAdapter) (io.WriteCloser, error) {
|
2018-05-09 17:20:11 -04:00
|
|
|
// Make sure to also open with read (in addition to write) to avoid borken pipe errors on plugin failure.
|
|
|
|
// It is up to the plugin to keep track of pipes that it should re-attach to, however.
|
|
|
|
// If the plugin doesn't open for reads, then the container will block once the pipe is full.
|
|
|
|
f, err := fifo.OpenFifo(context.Background(), a.fifoPath, unix.O_RDWR|unix.O_CREAT|unix.O_NONBLOCK, 0700)
|
2016-11-14 13:53:53 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrapf(err, "error creating i/o pipe for log plugin: %s", a.Name())
|
|
|
|
}
|
|
|
|
return f, nil
|
|
|
|
}
|