plugin_unix.go 818 B

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