unnamed_pipe


An unnamed pipe permits two related processes to communicate: typically, a parent and its child. One process sends output to the write end of the pipe, whereas the other process receives input from the read end of the pipe. A pipe automatically buffers its input to a maximum of 4K (BSD), or 40K (System V).

An os_unnamed_pipe is often used in conjunction with the os_process constructors to fork a child process using pipes for communication.

Library

Platform<ToolKit> for UNIX

Declaration

#include <ospace/unix/upipe.h>

class os_unnamed_pipe

Options

 

Legal I/O control:

O_NONBLOCK, O_CLOSE_ON_EXEC, O_ASYNC

Default I/O control:

0 (blocking)

Interface

Constructor
os_unnamed_pipe( os_ioctl_t control )
Constructs an object to reference a new unnamed pipe with I/O control setting control (default 0, blocking).

Throws: os_unix_toolkit_error

Destructor
~os_unnamed_pipe()
Destroys the object, closing the object's descriptor if necessary.
<
bool operator<( const os_unnamed_pipe& pipe ) const
Returns true if the object is considered to be less than pipe .
==
bool operator==( const os_unnamed_pipe& pipe ) const
Returns true if the object's read and write ends are the same as pipe .
(os_adapter)
operator os_adapter() const
Returns an os_adapter to the object.
auto_close
bool auto_close() const
Returns true if the object's pipe ends are closed on destruction.
auto_close
void auto_close( bool flag )
If flag is true , closes the object's pipe ends on destruction.
buffer_limit
long buffer_limit() const
Returns the maximum number of bytes that may be atomically written to pipe. If both of ends are closed, return OS_UNDEFINED .

Throws: os_unix_toolkit_error

clear
void clear()
Sets the object's state to good.
close
void close()
Closes both of the object's ends.

Throws: os_unix_toolkit_error

eof
bool eof() const
Returns true if the unnamed pipe is at the end of the object's input.
event_on_eof
void event_on_eof( bool flag )
If flag is true , the object generates an event on EOF.
event_on_eof
bool event_on_eof() const
Returns true if the object generates an event on EOF.
good
bool good() const
Returns true if the object is in a good state and not at EOF.
is_open
bool is_open() const
Returns true if either of the object's ends is open.
ok
bool ok() const
Returns true if the object has not failed.
print
void print( ostream& stream ) const
Prints pipe to stream .
read
ssize_t read( void* buffer , size_t bytes )
Reads up to the specified number of bytes of data into buffer from the pipe. Returns the number of bytes actually read, or returns -1 on error.

Throws: os_unix_toolkit_error

read_end
os_desc_t read_end()
Returns a reference to the object's read end.
write
ssize_t write( const void* buffer , size_t bytes )
Writes up to the specified number of bytes of data from buffer to the pipe. Returns the number of bytes actually written, or returns -1 on error.

Throws: os_unix_toolkit_error

write_end
os_desc_t write_end()
Returns a reference to the object's write end.

Non-Member Functions

<<
ostream& operator<<( ostream& stream , const os_unnamed_pipe& pipe )
Prints pipe to stream .
 

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only. - For use by licensed users only.