In file pipeexec/pipe_exec.hh:

class pipe_exec : public std iostream, public prog_exec

p2open equivalent

Inheritance:


Public Methods

explicit pipe_exec (const char* cmd, const char* mode = "rw")
Constructor
virtual ~pipe_exec ()
Destuctor
virtual void close ()
Closes the pipes
virtual bool operator! ()
Returns true on error
virtual int wait (int* stat_loc = 0, bool poll = false)
Wait for child to terminate (returns exit code) If poll is true, the method will not block and return 0 in case the child process is still alive
virtual int wait (double timeout, int* stat_loc = 0)
Wait for child to terminate with timeout
virtual const char* getmode () const
Returns the mode string

Protected Methods

virtual void setmode (const char* mode)
set the mode

Inherited from prog_exec:

Public Methods

virtual const char* cmd() const
virtual int pid() const
virtual bool kill(int sig)

Protected Methods

virtual bool parse(const char* cmd)
virtual void setcmd(const char* cmd)
virtual void setpid(int pid)
virtual const char* path() const
virtual char* const* args() const

Documentation

Pipe_exec. Starts a child process with fork, executes the string cmd with execlp and creates a bidirectional pipe to and from the child's standard input and standard output, respectively. pipe_exec inherits from iostream and the << and >> operators can be used to receive and send data from and to the child, respectively. This implementation uses non buffered output to make sure that the all characters are written to the child process before any read operation is performed. Child processes which use buffered IO might block the communication when they are trying to write a result back in the middle of receiving a block of data.

explicit pipe_exec(const char* cmd, const char* mode = "rw")
Constructor. Sets up the pipes and starts the child process.

virtual ~pipe_exec()
Destuctor. Sends a kill signal to the child

virtual void close()
Closes the pipes

virtual bool operator!()
Returns true on error

virtual int wait(int* stat_loc = 0, bool poll = false)
Wait for child to terminate (returns exit code) If poll is true, the method will not block and return 0 in case the child process is still alive. This method will return the same as waitpid and set the return status if stat_loc is non-zero.

virtual int wait(double timeout, int* stat_loc = 0)
Wait for child to terminate with timeout. If the time expires and the child process is still alive, the mothod will return 0. Otherwise, this method will return the same as waitpid and set the return status if stat_loc is non-zero. The timeout is in seconds. A timeout of 0 is equal to polling and a negative timeout will block.

virtual const char* getmode() const
Returns the mode string

virtual void setmode(const char* mode)
set the mode


This class has no child classes.

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++