fifo

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 9 Imported by: 1,025

README

fifo

PkgGoDev Build Status codecov Go Report Card

Go package for handling fifos in a sane way.

// OpenFifo opens a fifo. Returns io.ReadWriteCloser.
// Context can be used to cancel this function until open(2) has not returned.
// Accepted flags:
// - syscall.O_CREAT - create new fifo if one doesn't exist
// - syscall.O_RDONLY - open fifo only from reader side
// - syscall.O_WRONLY - open fifo only from writer side
// - syscall.O_RDWR - open fifo from both sides, never block on syscall level
// - syscall.O_NONBLOCK - return io.ReadWriteCloser even if other side of the
//     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)


// Read from a fifo to a byte array.
func (f *fifo) Read(b []byte) (int, error)


// Write from byte array to a fifo.
func (f *fifo) Write(b []byte) (int, error)


// Close the fifo. Next reads/writes will error. This method can also be used
// before open(2) has returned and fifo was never opened.
func (f *fifo) Close() error 

Project details

The fifo is a containerd sub-project, licensed under the Apache 2.0 license. As a containerd sub-project, you will find the:

information in our containerd/project repository.

Documentation

Index

Constants

View Source
const O_PATH = 010000000

Variables

View Source
var (
	ErrClosed      = errors.New("fifo closed")
	ErrCtrlClosed  = errors.New("control of closed fifo")
	ErrRdFrmWRONLY = errors.New("reading from write-only fifo")
	ErrReadClosed  = errors.New("reading from a closed fifo")
	ErrWrToRDONLY  = errors.New("writing to read-only fifo")
	ErrWriteClosed = errors.New("writing to a closed fifo")
)

Functions

func IsFifo

func IsFifo(path string) (bool, error)

IsFifo checks if a file is a (named pipe) fifo if the file does not exist then it returns false

func OpenFifo

func OpenFifo(ctx context.Context, fn string, flag int, perm os.FileMode) (io.ReadWriteCloser, error)

OpenFifo opens a fifo. Returns io.ReadWriteCloser. Context can be used to cancel this function until open(2) has not returned. Accepted flags:

  • syscall.O_CREAT - create new fifo if one doesn't exist
  • syscall.O_RDONLY - open fifo only from reader side
  • syscall.O_WRONLY - open fifo only from writer side
  • syscall.O_RDWR - open fifo from both sides, never block on syscall level
  • syscall.O_NONBLOCK - return io.ReadWriteCloser even if other side of the fifo isn't open. read/write will be connected after the actual fifo is open or after fifo is closed.

func OpenFifoDup2

func OpenFifoDup2(ctx context.Context, fn string, flag int, perm os.FileMode, fd int) (io.ReadWriteCloser, error)

OpenFifoDup2 is same as OpenFifo, but additionally creates a copy of the FIFO file descriptor with dup2 syscall.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL