WvStreams
wvpipe.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * Provides support for piping data to/from subprocesses.
6  */
7 #ifndef __WVPIPE_H
8 #define __WVPIPE_H
9 
10 #include "wvfdstream.h"
11 #include "wvsubproc.h"
12 
32 class WvPipe : public WvFDStream
33 {
34  WvSubProc proc;
35 protected:
36  void setup(const char *program, const char * const *argv,
37  bool writable, bool readable, bool catch_stderr,
38  int stdin_fd, int stdout_fd, int stderr_fd,
39  WvStringList *env);
40 public:
54  WvPipe(const char *program, const char * const *argv,
55  bool writable, bool readable, bool catch_stderr,
56  int stdin_fd = 0, int stdout_fd = 1, int stderr_fd = 2,
57  WvStringList *env = NULL);
58 
72  WvPipe(const char *program, const char * const *argv,
73  bool writable, bool readable, bool catch_stderr,
74  WvFDStream *stdin_str, WvFDStream *stdout_str = NULL,
75  WvFDStream *stderr_str = NULL, WvStringList *env = NULL);
76 
81  WvPipe(const char *program, const char **argv,
82  bool writable, bool readable, bool catch_stderr,
83  WvFDStream *stdio_str, WvStringList *env = NULL);
84 
86  virtual ~WvPipe();
87 
92  void kill(int signum);
93 
95  int finish(bool wait_children = true);
96 
98  bool child_exited();
99 
101  bool child_killed() const;
102 
108  int exit_status();
109 
110  // returns pid
111  int getpid() const { return proc.pid; };
112 
113  // callback to ignore everything. see comment in wvpipe.cc.
114  static void ignore_read(WvStream &s);
115 
116 public:
117  const char *wstype() const { return "WvPipe"; }
118 };
119 
120 #endif // __WVPIPE_H