plugin_unix.go 795 B

1234567891011121314151617181920212223
  1. //go:build linux || freebsd
  2. package logger // import "github.com/docker/docker/daemon/logger"
  3. import (
  4. "context"
  5. "io"
  6. "github.com/containerd/fifo"
  7. "github.com/pkg/errors"
  8. "golang.org/x/sys/unix"
  9. )
  10. func openPluginStream(a *pluginAdapter) (io.WriteCloser, error) {
  11. // Make sure to also open with read (in addition to write) to avoid borken pipe errors on plugin failure.
  12. // It is up to the plugin to keep track of pipes that it should re-attach to, however.
  13. // If the plugin doesn't open for reads, then the container will block once the pipe is full.
  14. f, err := fifo.OpenFifo(context.Background(), a.fifoPath, unix.O_RDWR|unix.O_CREAT|unix.O_NONBLOCK, 0o700)
  15. if err != nil {
  16. return nil, errors.Wrapf(err, "error creating i/o pipe for log plugin: %s", a.Name())
  17. }
  18. return f, nil
  19. }