Revendor latest containerd/fifo
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
parent
656b487d33
commit
5afc4b4d8b
@ -5,7 +5,7 @@ github.com/containerd/btrfs 153935315f4ab9be5bf03650a134
|
||||
github.com/containerd/cgroups 0b889c03f102012f1d93a97ddd3ef71cd6f4f510
|
||||
github.com/containerd/console v1.0.1
|
||||
github.com/containerd/continuity efbc4488d8fe1bdc16bde3b2d2990d9b3a899165
|
||||
github.com/containerd/fifo f15a3290365b9d2627d189e619ab4008e0069caf
|
||||
github.com/containerd/fifo cc76b10a4c47cdfac4bf6c373cc643628a72bfe9
|
||||
github.com/containerd/go-runc 7016d3ce2328dd2cb1192b2076ebd565c4e8df0c
|
||||
github.com/containerd/nri eb1350a75164f76de48e3605389e7a3fbc85d06e
|
||||
github.com/containerd/ttrpc v1.0.2
|
||||
|
19
vendor/github.com/containerd/fifo/fifo.go
generated
vendored
19
vendor/github.com/containerd/fifo/fifo.go
generated
vendored
@ -41,6 +41,21 @@ type fifo struct {
|
||||
|
||||
var leakCheckWg *sync.WaitGroup
|
||||
|
||||
// OpenFifoDup2 is same as OpenFifo, but additionally creates a copy of the FIFO file descriptor with dup2 syscall.
|
||||
func OpenFifoDup2(ctx context.Context, fn string, flag int, perm os.FileMode, fd int) (io.ReadWriteCloser, error) {
|
||||
f, err := openFifo(ctx, fn, flag, perm)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "fifo error")
|
||||
}
|
||||
|
||||
if err := syscall.Dup2(int(f.file.Fd()), fd); err != nil {
|
||||
_ = f.Close()
|
||||
return nil, errors.Wrap(err, "dup2 error")
|
||||
}
|
||||
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// OpenFifo opens a fifo. Returns io.ReadWriteCloser.
|
||||
// Context can be used to cancel this function until open(2) has not returned.
|
||||
// Accepted flags:
|
||||
@ -52,6 +67,10 @@ var leakCheckWg *sync.WaitGroup
|
||||
// fifo isn't open. read/write will be connected after the actual fifo is
|
||||
// open or after fifo is closed.
|
||||
func OpenFifo(ctx context.Context, fn string, flag int, perm os.FileMode) (io.ReadWriteCloser, error) {
|
||||
return openFifo(ctx, fn, flag, perm)
|
||||
}
|
||||
|
||||
func openFifo(ctx context.Context, fn string, flag int, perm os.FileMode) (*fifo, error) {
|
||||
if _, err := os.Stat(fn); err != nil {
|
||||
if os.IsNotExist(err) && flag&syscall.O_CREAT != 0 {
|
||||
if err := mkfifo(fn, uint32(perm&os.ModePerm)); err != nil && !os.IsExist(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user