Logo Search packages:      
Sourcecode: wvstreams version File versions

WvPipe Class Reference

#include <wvpipe.h>

Inheritance diagram for WvPipe:

WvFdStream WvStream WvErrorBase IObject

List of all members.

Detailed Description

Implementation of a WvPipe stream. These allow you to create a new process, attaching its stdin/stdout to a WvStream.

Unlike pipes created with the popen() system call, you can capture both stdin and stdout for the given process. This is because we actually use the socketpair() call instead. If you try this, however, you must be very careful to always use the select() call before reading from the stream. (Think what would happen if both ends of the pipe do a read() simultaneously!)

Note that we do not go as far as actually using a pty. That means programs which deliberately open /dev/tty will not be redirected.

When the WvPipe is destroyed, it makes sure that the child process is killed. Since it tries to do it politely (SIGTERM, wait up to 2 seconds, SIGKILL) it can take up to 2 seconds to destroy a WvPipe.

Definition at line 32 of file wvpipe.h.

Public Member Functions

void _callback ()
void * _callwrap (void *)
virtual unsigned int addRef ()=0
void alarm (time_t msec_timeout)
time_t alarm_remaining ()
void auto_flush (bool is_automatic)
void autoforward (WvStream &s)
virtual void callback ()
bool child_exited ()
bool child_killed () const
virtual void close ()
virtual size_t continue_read (time_t wait_msec, WvBuf &outbuf, size_t count)
virtual size_t continue_read (time_t wait_msec, void *buf, size_t count)
bool continue_select (time_t msec_timeout)
void delay_output (bool is_delayed)
void drain ()
virtual WvString errstr () const
int exit_status ()
int finish (bool wait_children=true)
virtual bool flush (time_t msec_timeout)
void flush_then_close (int msec_timeout)
void force_select (bool readable, bool writable, bool isexception=false)
virtual int geterr () const
int getfd () const
virtual IObjectgetInterface (const UUID &)=0
char * getline (time_t wait_msec, char separator= '\n', int readahead=1024)
int getpid () const
int getrfd () const
virtual IWeakRefgetWeakRef ()=0
int getwfd () const
virtual bool isok () const
virtual bool isreadable ()
virtual bool iswritable ()
void kill (int signum)
virtual void maybe_autoclose ()
void noautoforward ()
void noerr ()
virtual void noread ()
virtual void nowrite ()
size_t operator() (WVSTRING_FORMAT_DECL)
size_t operator() (WvStringParm s)
void outbuf_limit (size_t size)
bool post_select (SelectInfo &si, const SelectRequest &r)
virtual bool post_select (SelectInfo &si)
bool pre_select (SelectInfo &si, const SelectRequest &r)
virtual bool pre_select (SelectInfo &si)
size_t print (WvStringParm s)
void queuemin (size_t count)
virtual size_t read (WvBuf &outbuf, size_t count)
virtual size_t read (void *buf, size_t count)
size_t read_until (void *buf, size_t count, time_t wait_msec, char separator)
virtual unsigned int release ()=0
void runonce (time_t msec_timeout=-1)
bool select (time_t msec_timeout, bool readable, bool writable, bool isex=false)
bool select (time_t msec_timeout)
void setcallback (WvStreamCallback _callfunc, void *_userdata)
void setclosecallback (WvStreamCallback _callfunc, void *_userdata)
void seterr (const WvErrorBase &err)
void seterr (WvStringParm specialerr)
virtual void seterr (int _errnum)
virtual bool should_flush ()
virtual const WvAddrsrc () const
void terminate_continue_select ()
void undo_force_select (bool readable, bool writable, bool isexception=false)
virtual void unread (WvBuf &outbuf, size_t count)
virtual size_t uread (void *buf, size_t count)
virtual size_t uwrite (const void *buf, size_t count)
size_t write (WvStringParm s)
virtual size_t write (WvBuf &inbuf, size_t count=INT_MAX)
virtual size_t write (const void *buf, size_t count)
 WvPipe (const char *program, const char **argv, bool writable, bool readable, bool catch_stderr, WvFDStream *stdio_str)
 WvPipe (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, WvFDStream *stdin_str, WvFDStream *stdout_str=NULL, WvFDStream *stderr_str=NULL)
 WvPipe (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, int stdin_fd=0, int stdout_fd=1, int stderr_fd=2)
bool xpost_select (SelectInfo &si, const SelectRequest &r)
bool xpre_select (SelectInfo &si, const SelectRequest &r)
virtual ~WvPipe ()

Static Public Member Functions

static void autoforward_callback (WvStream &s, void *userdata)
static void ignore_read (WvStream &s, void *userdata)

Public Attributes

bool alarm_was_ticking
bool closed
SelectRequest force
size_t personal_stack_size
bool stop_read
bool stop_write
bool uses_continue_select

Protected Member Functions

bool _build_selectinfo (SelectInfo &si, time_t msec_timeout, bool readable, bool writable, bool isexcept, bool forceable)
int _do_select (SelectInfo &si)
bool _process_selectinfo (SelectInfo &si, bool forceable)
virtual void execute ()
virtual bool flush_internal (time_t msec_timeout)
bool flush_outbuf (time_t msec_timeout)
void setfd (int fd)
void setup (const char *program, const char *const *argv, bool writable, bool readable, bool catch_stderr, int stdin_fd, int stdout_fd, int stderr_fd)

Protected Attributes

WvTime alarm_time
time_t autoclose_time
WvCallback< void *, void * > call_ctx
WvStreamCallback callfunc
void * closecb_data
WvStreamCallback closecb_func
int errnum
WvString errstring
WvDynBuf inbuf
bool is_auto_flush
bool is_flushing
WvTime last_alarm_check
size_t max_outbuf_size
WvDynBuf outbuf
bool outbuf_delayed_flush
size_t queue_min
int rfd
bool shutdown_read
bool shutdown_write
void * userdata
bool want_to_flush
int wfd
bool wvstream_execute_called

Static Protected Attributes

static WvStreamglobalstream = NULL

Private Attributes

WvSubProc proc

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index