[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

pipe

Pipe manager (QNX Neutrino)


Note: You must be root to start this manager.

Syntax:

pipe [-1] [-a atomic_write_size] 
     [-P] [-s pipe_buffer_size] &

Options:

-1
Unblock select for writing when _PC_PIPE_BUF bytes are available (the default 1 is byte). See the description section to know about _PC_PIPE_BUF.
-a
Set atomic write size for _PC_PIPE_BUF (the default is 5120 bytes). See the description section to know about _PC_PIPE_BUF
-P
Synchronize the modification of POSIX attributes to host filesystem.
-s
Set total buffer size (the default is 5120 bytes).

Description:

The pipe manager implements the subset of file I/O known as pipes (or anonymous FIFOs). A simple form of interprocess communication, pipes are mostly used to connect the output of one process to the input of another to form a series of filters.


Note: This pipe is backward compatible. When you invoke pipe server with no arguments, the behavior you get is identical to the earlier versions of pipe.

The atomic_write_size is the size for which it's guaranteed that a write() of data won't be interleaved with data from any other process; in other words the amount of data that will be written atomically. This is required when there are multiple writers sending data to a single reader. The POSIX maximum is referred to as PIPE_BUF, and can be queried at runtime using fpathconf(_PC_PIPE_BUF). It isn't recommended to lower this value from the default 5120 bytes in case application code is using the PIPE_BUF manifest from limits.h rather than a runtime fpathconf() determination.

The pipe_buffer_size is the total buffer size of the pipe (and must be at least the atomic write size). Effectively the pipe utility can hold this many (un-read()) bytes before write() clients start to block or fail with EAGAIN (based on their O_NONBLOCK orientation). The QNX Neutrino value has been identical to PIPE_BUF, leading to some confusion between the two items (mainly that PIPE_BUF was actually the size of the pipe buffer rather than the atomic write size, but it only coincidentally had the same numeric value). There is no simple mechanism (such as fpathconf()) to query the pipe buffering capacity, but it can be determined by writing one-byte-at-a-time to an empty O_NONBLOCK pipe and counting how many are consumed until an EAGAIN error (full pipe indication) is returned. Increasing this value could make pipelines more elastic, in terms of de-coupling the writer from the reader processes, at the expense of using extra system memory for each pipe. Across a sample of OSs, pipe buffering capacity is in the 4-16 KB range.

Let's now discuss how the -P option works. Strict POSIX conformance requires that the atime and mtime attributes of a FIFO are updated for every read() and write() operation. As FIFOs operate by redirecting access of the FIFO from the host filesystem to the pipe server, maintaining these attributes requires additional synchronization messages from the pipe server back to the host filesystem. In most cases this level of synchronization isn't required, and by default is only performed at the last close() of the FIFO.

The -1 option sets the behavior for select() write notification of the pipe utility. The original behavior was to satisfy or unblock select() clients even if 1 byte of buffer space was available. POSIX specifies a different behavior. Since the atomic write size and the total buffer size are equal and equal to 5120 bytes, select() would be satisfied only on an empty pipe, which may impact performance or establish a lock-step timing between the writing and reading processes. If this option is enabled, consider also increasing the -s to be larger than PIPE_BUF so that the pipe doesn't have to completely drain before a select() for write is satisfied.

Exit status:

The pipe utility terminates only if an error occurs during startup. If pipe fails during startup, it prints a diagnostic message to the standard output stream and then exits with a nonzero status.

See also:

mqueue

Controlling How Neutrino Starts in the Neutrino User's Guide


[Previous] [Contents] [Index] [Next]