WvStreams
include/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
32class WvPipe : public WvFDStream
33{
34 WvSubProc proc;
35protected:
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);
40public:
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
99
101 bool child_killed() const;
102
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
116public:
117 const char *wstype() const { return "WvPipe"; }
118};
119
120#endif // __WVPIPE_H
Base class for streams built on Unix file descriptors.
Implementation of a WvPipe stream.
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, WvStringList *env=NULL)
default pipe constructor; if you just want to use a pipe, use this.
bool child_exited()
returns true if child is dead.
int finish(bool wait_children=true)
wait for child to die.
WvPipe(const char *program, const char **argv, bool writable, bool readable, bool catch_stderr, WvFDStream *stdio_str, WvStringList *env=NULL)
This constructor is the same again, except that it uses the features of the WvFDStream class to get a...
int exit_status()
returns the exit status: if child_killed()==true, the signal that killed the child.
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, WvStringList *env=NULL)
This constructor does much the same thing as the previous one, except that std*_str are WvStreams ins...
void kill(int signum)
send the child a signal (signal names are defined in signal.h)
virtual ~WvPipe()
kill the child process and close the stream.
bool child_killed() const
returns true if child is dead because of a signal.
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
This is a WvList of WvStrings, and is a really handy way to parse strings.