WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Provides support for piping data to/from subprocesses. 00006 */ 00007 #ifndef __WVPIPE_H 00008 #define __WVPIPE_H 00009 00010 #include "wvfdstream.h" 00011 #include "wvsubproc.h" 00012 00032 class WvPipe : public WvFDStream 00033 { 00034 WvSubProc proc; 00035 protected: 00036 void setup(const char *program, const char * const *argv, 00037 bool writable, bool readable, bool catch_stderr, 00038 int stdin_fd, int stdout_fd, int stderr_fd, 00039 WvStringList *env); 00040 public: 00054 WvPipe(const char *program, const char * const *argv, 00055 bool writable, bool readable, bool catch_stderr, 00056 int stdin_fd = 0, int stdout_fd = 1, int stderr_fd = 2, 00057 WvStringList *env = NULL); 00058 00072 WvPipe(const char *program, const char * const *argv, 00073 bool writable, bool readable, bool catch_stderr, 00074 WvFDStream *stdin_str, WvFDStream *stdout_str = NULL, 00075 WvFDStream *stderr_str = NULL, WvStringList *env = NULL); 00076 00081 WvPipe(const char *program, const char **argv, 00082 bool writable, bool readable, bool catch_stderr, 00083 WvFDStream *stdio_str, WvStringList *env = NULL); 00084 00086 virtual ~WvPipe(); 00087 00092 void kill(int signum); 00093 00095 int finish(bool wait_children = true); 00096 00098 bool child_exited(); 00099 00101 bool child_killed() const; 00102 00108 int exit_status(); 00109 00110 // returns pid 00111 int getpid() const { return proc.pid; }; 00112 00113 // callback to ignore everything. see comment in wvpipe.cc. 00114 static void ignore_read(WvStream &s); 00115 00116 public: 00117 const char *wstype() const { return "WvPipe"; } 00118 }; 00119 00120 #endif // __WVPIPE_H