30 #ifndef REDI_PSTREAM_H_SEEN 31 #define REDI_PSTREAM_H_SEEN 43 #include <sys/types.h> 45 #include <sys/ioctl.h> 47 # include <sys/filio.h> 52 #if REDI_EVISCERATE_PSTREAMS 58 #define PSTREAMS_VERSION 0x0080 // 0.8.0 79 typedef std::ios_base::openmode
pmode;
87 static const pmode
pstdin = std::ios_base::out;
88 static const pmode
pstdout = std::ios_base::in;
89 static const pmode
pstderr = std::ios_base::app;
97 template <
typename CharT,
typename Traits = std::
char_traits<CharT> >
99 :
public std::basic_streambuf<CharT, Traits>
104 typedef CharT char_type;
105 typedef Traits traits_type;
106 typedef typename traits_type::int_type int_type;
107 typedef typename traits_type::off_type off_type;
108 typedef typename traits_type::pos_type pos_type;
128 open(
const std::string& command,
pmode mode);
140 kill(
int signal = SIGTERM);
144 killpg(
int signal = SIGTERM);
152 read_err(
bool readerr =
true);
162 #if REDI_EVISCERATE_PSTREAMS 165 fopen(FILE*& in, FILE*& out, FILE*& err);
179 overflow(int_type c);
187 pbackfail(int_type c = traits_type::eof());
195 xsputn(
const char_type* s, std::streamsize n);
199 write(
const char_type* s, std::streamsize n);
203 read(char_type* s, std::streamsize n);
219 wait(
bool nohang =
false);
234 create_buffers(
pmode mode);
237 destroy_buffers(
pmode mode);
244 fill_buffer(
bool non_blocking =
false);
264 char_type* rbuffer_[2];
265 char_type* rbufstate_[3];
273 template <
typename CharT,
typename Traits = std::
char_traits<CharT> >
275 :
virtual public std::basic_ios<CharT, Traits>
291 pstream_common(
const std::string& file,
const argv_type& argv, pmode mode);
299 do_open(
const std::string& command, pmode mode);
303 do_open(
const std::string& file,
const argv_type& argv, pmode mode);
322 #if REDI_EVISCERATE_PSTREAMS 325 fopen(FILE*& in, FILE*& out, FILE*& err);
344 template <
typename CharT,
typename Traits = std::
char_traits<CharT> >
346 :
public std::basic_istream<CharT, Traits>
350 typedef std::basic_istream<CharT, Traits> istream_type;
353 using pbase_type::buf_;
364 typedef typename pbase_type::pmode
pmode;
371 : istream_type(NULL), pbase_type()
385 : istream_type(NULL), pbase_type(command, readable(mode))
400 const argv_type& argv,
402 : istream_type(NULL), pbase_type(file, argv, readable(mode))
416 : istream_type(NULL), pbase_type(argv.at(0), argv, mode|
pstdout)
439 this->do_open(command, readable(mode));
454 const argv_type& argv,
457 this->do_open(file, argv, readable(mode));
467 this->buf_.read_err(
false);
478 this->buf_.read_err(
true);
493 template <
typename CharT,
typename Traits = std::
char_traits<CharT> >
495 :
public std::basic_ostream<CharT, Traits>
499 typedef std::basic_ostream<CharT, Traits> ostream_type;
502 using pbase_type::buf_;
506 typedef typename pbase_type::pmode
pmode;
513 : ostream_type(NULL), pbase_type()
527 : ostream_type(NULL), pbase_type(command, mode|
pstdin)
542 const argv_type& argv,
544 : ostream_type(NULL), pbase_type(file, argv, mode|
pstdin)
558 : ostream_type(NULL), pbase_type(argv.at(0), argv, mode|
pstdin)
580 this->do_open(command, mode|
pstdin);
595 const argv_type& argv,
598 this->do_open(file, argv, mode|
pstdin);
616 template <
typename CharT,
typename Traits = std::
char_traits<CharT> >
618 :
public std::basic_iostream<CharT, Traits>
622 typedef std::basic_iostream<CharT, Traits> iostream_type;
625 using pbase_type::buf_;
629 typedef typename pbase_type::pmode
pmode;
636 : iostream_type(NULL), pbase_type()
650 : iostream_type(NULL), pbase_type(command, mode)
665 const argv_type& argv,
667 : iostream_type(NULL), pbase_type(file, argv, mode)
681 : iostream_type(NULL), pbase_type(argv.at(0), argv, mode)
703 this->do_open(command, mode);
718 const argv_type& argv,
721 this->do_open(file, argv, mode);
731 this->buf_.read_err(
false);
742 this->buf_.read_err(
true);
769 template <
typename CharT,
typename Traits = std::
char_traits<CharT> >
771 :
public std::basic_ostream<CharT, Traits>
772 ,
private std::basic_istream<CharT, Traits>
776 typedef std::basic_ostream<CharT, Traits> ostream_type;
777 typedef std::basic_istream<CharT, Traits> istream_type;
780 using pbase_type::buf_;
784 typedef typename pbase_type::pmode
pmode;
791 : ostream_type(NULL), istream_type(NULL), pbase_type()
805 : ostream_type(NULL) , istream_type(NULL) , pbase_type(command, mode)
820 const argv_type& argv,
822 : ostream_type(NULL), istream_type(NULL), pbase_type(file, argv, mode)
836 : ostream_type(NULL), istream_type(NULL),
837 pbase_type(argv.at(0), argv, mode)
855 this->do_open(command, mode);
870 const argv_type& argv,
873 this->do_open(file, argv, mode);
884 this->buf_.read_err(
false);
896 this->buf_.read_err(
true);
926 template <
typename C,
typename T>
927 inline std::basic_ostream<C,T>&
928 peof(std::basic_ostream<C,T>& s)
931 if (pstreambuf* p = dynamic_cast<pstreambuf*>(s.rdbuf()))
948 template <
typename C,
typename T>
969 template <
typename C,
typename T>
992 template <
typename C,
typename T>
1005 open(file, argv, mode);
1012 template <
typename C,
typename T>
1046 template <
typename C,
typename T>
1050 const char * shell_path =
"/bin/sh";
1052 const std::string argv[] = {
"sh",
"-c", command };
1053 return this->
open(shell_path,
argv_type(argv, argv+3), mode);
1063 ::execl(shell_path,
"sh",
"-c", command.c_str(), (
char*)NULL);
1078 create_buffers(mode);
1097 if (fd >= 0 && ::
close(fd) == 0)
1115 for (std::size_t i = 0; i < N; ++i)
1148 template <
typename C,
typename T>
1162 fd_type ck_exec[] = { -1, -1 };
1163 if (-1 == ::pipe(ck_exec)
1164 || -1 == ::fcntl(ck_exec[RD], F_SETFD, FD_CLOEXEC)
1165 || -1 == ::fcntl(ck_exec[WR], F_SETFD, FD_CLOEXEC))
1177 char** arg_v =
new char*[argv.size()+1];
1178 for (std::size_t i = 0; i < argv.size(); ++i)
1180 const std::string& src = argv[i];
1181 char*& dest = arg_v[i];
1182 dest =
new char[src.size()+1];
1183 dest[ src.copy(dest, src.size()) ] =
'\0';
1185 arg_v[argv.size()] = NULL;
1187 ::execvp(file.c_str(), arg_v);
1194 while (::
write(ck_exec[WR], &error_,
sizeof(error_)) == -1
1215 switch (::
read(ck_exec[RD], &error_,
sizeof(error_)))
1219 create_buffers(mode);
1254 template <
typename C,
typename T>
1263 fd_type fd[] = { -1, -1, -1, -1, -1, -1 };
1275 if (!error_ && mode&
pstdin && ::pipe(pin))
1278 if (!error_ && mode&
pstdout && ::pipe(pout))
1281 if (!error_ && mode&
pstderr && ::pipe(perr))
1299 ::dup2(pin[RD], STDIN_FILENO);
1305 ::dup2(pout[WR], STDOUT_FILENO);
1311 ::dup2(perr[WR], STDERR_FILENO);
1315 #ifdef _POSIX_JOB_CONTROL 1343 rpipe_[rsrc_out] = pout[RD];
1348 rpipe_[rsrc_err] = perr[RD];
1371 template <
typename C,
typename T>
1375 const bool running =
is_open();
1391 }
while (
wait() == -1 &&
error() == EINTR);
1393 return running ?
this : NULL;
1399 template <
typename C,
typename T>
1403 rpipe_[rsrc_out] = rpipe_[rsrc_err] = -1;
1404 rbuffer_[rsrc_out] = rbuffer_[rsrc_err] = NULL;
1405 rbufstate_[0] = rbufstate_[1] = rbufstate_[2] = NULL;
1408 template <
typename C,
typename T>
1415 wbuffer_ =
new char_type[bufsz];
1416 this->setp(wbuffer_, wbuffer_ + bufsz);
1420 delete[] rbuffer_[rsrc_out];
1421 rbuffer_[rsrc_out] =
new char_type[bufsz];
1423 this->setg(rbuffer_[rsrc_out] + pbsz, rbuffer_[rsrc_out] + pbsz,
1424 rbuffer_[rsrc_out] + pbsz);
1428 delete[] rbuffer_[rsrc_err];
1429 rbuffer_[rsrc_err] =
new char_type[bufsz];
1430 if (!(mode & pstdout))
1433 this->setg(rbuffer_[rsrc_err] + pbsz, rbuffer_[rsrc_err] + pbsz,
1434 rbuffer_[rsrc_err] + pbsz);
1439 template <
typename C,
typename T>
1445 this->setp(NULL, NULL);
1451 if (rsrc_ == rsrc_out)
1452 this->setg(NULL, NULL, NULL);
1453 delete[] rbuffer_[rsrc_out];
1454 rbuffer_[rsrc_out] = NULL;
1458 if (rsrc_ == rsrc_err)
1459 this->setg(NULL, NULL, NULL);
1460 delete[] rbuffer_[rsrc_err];
1461 rbuffer_[rsrc_err] = NULL;
1465 template <
typename C,
typename T>
1471 char_type* tmpbufstate[] = {this->eback(), this->gptr(), this->egptr()};
1472 this->setg(rbufstate_[0], rbufstate_[1], rbufstate_[2]);
1473 for (std::size_t i = 0; i < 3; ++i)
1474 rbufstate_[i] = tmpbufstate[i];
1496 template <
typename C,
typename T>
1504 switch(::waitpid(ppid_, &status, nohang ? WNOHANG : 0))
1539 template <
typename C,
typename T>
1546 if (::
kill(ppid_, signal))
1552 if (signal==SIGTERM || signal==SIGKILL)
1574 template <
typename C,
typename T>
1579 #ifdef _POSIX_JOB_CONTROL 1582 pid_t pgid = ::getpgid(ppid_);
1585 else if (pgid == ::getpgrp())
1587 else if (::
killpg(pgid, signal))
1603 template <
typename C,
typename T>
1607 return ppid_ == 0 ||
wait(
true)==1;
1616 template <
typename C,
typename T>
1626 template <
typename C,
typename T>
1637 template <
typename C,
typename T>
1656 template <
typename C,
typename T>
1671 template <
typename C,
typename T>
1678 switch_read_buffer(src);
1694 template <
typename C,
typename T>
1695 typename basic_pstreambuf<C,T>::int_type
1699 return traits_type::eof();
1700 else if (!traits_type::eq_int_type(c, traits_type::eof()))
1701 return this->sputc(c);
1703 return traits_type::not_eof(c);
1707 template <
typename C,
typename T>
1719 template <
typename C,
typename T>
1723 std::streamsize done = 0;
1726 if (std::streamsize nbuf = this->epptr() - this->pptr())
1728 nbuf = std::min(nbuf, n - done);
1729 traits_type::copy(this->pptr(), s + done, nbuf);
1742 template <
typename C,
typename T>
1746 const std::streamsize count = this->pptr() - this->pbase();
1749 const std::streamsize written = this->
write(this->wbuffer_, count);
1752 if (
const std::streamsize unwritten = count - written)
1753 traits_type::move(this->pbase(), this->pbase()+written, unwritten);
1754 this->pbump(-written);
1768 template <
typename C,
typename T>
1769 typename basic_pstreambuf<C,T>::int_type
1772 if (this->gptr() < this->egptr() ||
fill_buffer())
1773 return traits_type::to_int_type(*this->gptr());
1775 return traits_type::eof();
1786 template <
typename C,
typename T>
1787 typename basic_pstreambuf<C,T>::int_type
1790 if (this->gptr() != this->eback())
1793 if (!traits_type::eq_int_type(c, traits_type::eof()))
1794 *this->gptr() = traits_type::to_char_type(c);
1795 return traits_type::not_eof(c);
1798 return traits_type::eof();
1801 template <
typename C,
typename T>
1806 if (
sizeof(char_type) == 1)
1807 avail =
fill_buffer(
true) ? this->egptr() - this->gptr() : -1;
1811 if (::ioctl(
rpipe(), FIONREAD, &avail) == -1)
1814 avail /=
sizeof(char_type);
1817 return std::streamsize(avail);
1823 template <
typename C,
typename T>
1827 const std::streamsize pb1 = this->gptr() - this->eback();
1828 const std::streamsize pb2 = pbsz;
1829 const std::streamsize npb = std::min(pb1, pb2);
1831 char_type*
const rbuf =
rbuffer();
1833 traits_type::move(rbuf + pbsz - npb, this->gptr() - npb, npb);
1835 std::streamsize rc = -1;
1839 const int flags = ::fcntl(
rpipe(), F_GETFL);
1842 const bool blocking = !(flags & O_NONBLOCK);
1844 ::fcntl(
rpipe(), F_SETFL, flags | O_NONBLOCK);
1847 rc =
read(rbuf + pbsz, bufsz - pbsz);
1849 if (rc == -1 && error_ == EAGAIN)
1855 ::fcntl(
rpipe(), F_SETFL, flags);
1859 rc =
read(rbuf + pbsz, bufsz - pbsz);
1861 if (rc > 0 || (rc == 0 && non_blocking))
1863 this->setg( rbuf + pbsz - npb,
1870 this->setg(NULL, NULL, NULL);
1882 template <
typename C,
typename T>
1883 inline std::streamsize
1886 std::streamsize nwritten = 0;
1893 nwritten /=
sizeof(char_type);
1905 template <
typename C,
typename T>
1906 inline std::streamsize
1909 std::streamsize nread = 0;
1912 nread =
::read(
rpipe(), s, n *
sizeof(char_type));
1916 nread /=
sizeof(char_type);
1922 template <
typename C,
typename T>
1930 template <
typename C,
typename T>
1934 return rpipe_[rsrc_];
1938 template <
typename C,
typename T>
1942 return rpipe_[which];
1946 template <
typename C,
typename T>
1947 inline typename basic_pstreambuf<C,T>::char_type*
1950 return rbuffer_[rsrc_];
1967 template <
typename C,
typename T>
1970 : std::basic_ios<C,T>(NULL)
1974 this->std::basic_ios<C,T>::rdbuf(&
buf_);
1985 template <
typename C,
typename T>
1988 : std::basic_ios<C,T>(NULL)
1992 this->std::basic_ios<C,T>::rdbuf(&
buf_);
2005 template <
typename C,
typename T>
2010 : std::basic_ios<C,T>(NULL)
2014 this->std::basic_ios<C,T>::rdbuf(&
buf_);
2027 template <
typename C,
typename T>
2041 template <
typename C,
typename T>
2046 this->setstate(std::ios_base::failbit);
2058 template <
typename C,
typename T>
2065 this->setstate(std::ios_base::failbit);
2069 template <
typename C,
typename T>
2074 this->setstate(std::ios_base::failbit);
2081 template <
typename C,
typename T>
2089 template <
typename C,
typename T>
2090 inline const std::string&
2098 template <
typename C,
typename T>
2106 #if REDI_EVISCERATE_PSTREAMS 2139 template <
typename C,
typename T>
2143 in = out = err = NULL;
2144 std::size_t open_files = 0;
2147 if ((in = ::fdopen(wpipe(),
"w")))
2152 if (rpipe(rsrc_out) > -1)
2154 if ((out = ::fdopen(rpipe(rsrc_out),
"r")))
2159 if (rpipe(rsrc_err) > -1)
2161 if ((err = ::fdopen(rpipe(rsrc_err),
"r")))
2179 template <
typename C,
typename T>
2183 return buf_.fopen(fin, fout, ferr);
2186 #endif // REDI_EVISCERATE_PSTREAMS 2196 #endif // REDI_PSTREAM_H_SEEN void close_fd(pstreams::fd_type &fd)
Helper function to close a file descriptor.
Definition: pstream.h:1095
basic_pstream(const std::string &command, pmode mode=pstdout|pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:649
int_type overflow(int_type c)
Transfer characters to the pipe when character buffer overflows.
Definition: pstream.h:1696
std::streamsize write(const char_type *s, std::streamsize n)
Insert a sequence of characters into the pipe.
Definition: pstream.h:1884
int error() const
Return the error number (errno) for the most recent failed operation.
Definition: pstream.h:1628
pbase_type::argv_type argv_type
Type used to hold the arguments for a command.
Definition: pstream.h:787
fd_type fd_t
Definition: pstream.h:110
~basic_pstream()
Destructor.
Definition: pstream.h:689
fd_type & wpipe()
Return the file descriptor for the output pipe.
Definition: pstream.h:1924
Class template for Bidirectional PStreams.
Definition: pstream.h:617
char_type * rbuffer()
Return the active input buffer.
Definition: pstream.h:1948
Class template for stream buffer.
Definition: pstream.h:98
pbase_type::pmode pmode
Type used to specify how to connect to the process.
Definition: pstream.h:364
std::streamsize read(char_type *s, std::streamsize n)
Extract a sequence of characters from the pipe.
Definition: pstream.h:1907
basic_rpstream()
Default constructor, creates an uninitialised stream.
Definition: pstream.h:790
void open(const std::string &command, pmode mode=pstdout|pstdin)
Start a process.
Definition: pstream.h:853
basic_pstream()
Default constructor, creates an uninitialised stream.
Definition: pstream.h:635
pbase_type::pmode pmode
Type used to specify how to connect to the process.
Definition: pstream.h:506
bool read_err(bool readerr=true)
Change active input source.
Definition: pstream.h:1673
basic_rpstream(const std::string &command, pmode mode=pstdout|pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:804
virtual ~pstream_common()=0
Pure virtual destructor.
Definition: pstream.h:2029
void close_fd_array(pstreams::fd_type(&fds)[N])
Helper function to close an array of file descriptors.
Definition: pstream.h:1113
std::vector< std::string > argv_type
Type used to hold the arguments for a command.
Definition: pstream.h:82
pbase_type::argv_type argv_type
Type used to hold the arguments for a command.
Definition: pstream.h:367
pstream_common()
Default constructor.
Definition: pstream.h:1969
int_type underflow()
Transfer characters from the pipe when the character buffer is empty.
Definition: pstream.h:1770
void open(const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin)
Start a process.
Definition: pstream.h:869
Class template for common base class.
Definition: pstream.h:274
basic_rpstream(const argv_type &argv, pmode mode=pstdout|pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:835
basic_ipstream(const argv_type &argv, pmode mode=pstdout)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:415
basic_pstream(const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:664
basic_opstream()
Default constructor, creates an uninitialised stream.
Definition: pstream.h:512
basic_pstreambuf< char > pstreambuf
Type definition for common template specialisation.
Definition: pstream.h:903
static const pmode pstderr
Read from stderr.
Definition: pstream.h:89
streambuf_type * rdbuf() const
Return a pointer to the stream buffer.
Definition: pstream.h:2100
int_type pbackfail(int_type c=traits_type::eof())
Make a character available to be returned by the next extraction.
Definition: pstream.h:1788
Common base class providing constants and typenames.
Definition: pstream.h:76
bool fill_buffer(bool non_blocking=false)
Definition: pstream.h:1825
static const pmode pstdout
Read from stdout.
Definition: pstream.h:88
int sync()
Write any buffered characters to the stream.
Definition: pstream.h:1709
basic_rpstream(const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:819
basic_pstreambuf()
Default constructor.
Definition: pstream.h:950
basic_ipstream(const std::string &command, pmode mode=pstdout)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:384
std::string command_
The command used to start the process.
Definition: pstream.h:329
bool exited()
Report whether the process has exited.
Definition: pstream.h:1605
streambuf_type buf_
The stream buffer.
Definition: pstream.h:330
buf_read_src
Enumerated type to indicate whether stdout or stderr is to be read.
Definition: pstream.h:211
basic_pstream & out()
Set streambuf to read from process' stdout.
Definition: pstream.h:729
bool is_open() const
Report whether the stream's buffer has been initialised.
Definition: pstream.h:2083
basic_ipstream(const std::string &file, const argv_type &argv, pmode mode=pstdout)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:399
Class template for Input PStreams.
Definition: pstream.h:345
pbase_type::argv_type argv_type
Type used to hold the arguments for a command.
Definition: pstream.h:632
std::streamsize xsputn(const char_type *s, std::streamsize n)
Insert multiple characters into the pipe.
Definition: pstream.h:1721
pid_t fork(pmode mode)
Initialise pipes and fork process.
Definition: pstream.h:1256
void open(const std::string &command, pmode mode=pstdin)
Start a process.
Definition: pstream.h:578
basic_ipstream & err()
Set streambuf to read from process' stderr.
Definition: pstream.h:476
basic_pstream & err()
Set streambuf to read from process' stderr.
Definition: pstream.h:740
basic_opstream(const argv_type &argv, pmode mode=pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:557
basic_rpstream< char > rpstream
Type definition for common template specialisation.
Definition: pstream.h:911
basic_ipstream & out()
Set streambuf to read from process' stdout.
Definition: pstream.h:465
void open(const std::string &command, pmode mode=pstdout|pstdin)
Start a process.
Definition: pstream.h:701
pbase_type::argv_type argv_type
Type used to hold the arguments for a command.
Definition: pstream.h:509
All PStreams classes are declared in namespace redi.
int fd_type
Type used for file descriptors.
Definition: pstream.h:85
~basic_pstreambuf()
Destructor.
Definition: pstream.h:1014
basic_pstream(const argv_type &argv, pmode mode=pstdout|pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:680
std::ios_base::openmode pmode
Type used to specify how to connect to the process.
Definition: pstream.h:79
Class template for Restricted PStreams.
Definition: pstream.h:770
basic_pstreambuf * killpg(int signal=SIGTERM)
Send a signal to the process' process group.
Definition: pstream.h:1576
basic_pstreambuf * close()
Close the stream buffer and wait for the process to exit.
Definition: pstream.h:1373
bool is_open() const
Report whether the stream buffer has been initialised.
Definition: pstream.h:1658
bool empty_buffer()
Writes buffered characters to the process' stdin pipe.
Definition: pstream.h:1744
void do_open(const std::string &command, pmode mode)
Start a process.
Definition: pstream.h:2043
~basic_ipstream()
Destructor.
Definition: pstream.h:424
pbase_type::pmode pmode
Type used to specify how to connect to the process.
Definition: pstream.h:784
std::basic_ostream< C, T > & peof(std::basic_ostream< C, T > &s)
Manipulator to close the pipe connected to the process' stdin.
Definition: pstream.h:928
basic_ipstream< char > ipstream
Type definition for common template specialisation.
Definition: pstream.h:905
void open(const std::string &command, pmode mode=pstdout)
Start a process.
Definition: pstream.h:437
int wait(bool nohang=false)
Wait for the child process to exit.
Definition: pstream.h:1498
void open(const std::string &file, const argv_type &argv, pmode mode=pstdout)
Start a process.
Definition: pstream.h:453
Class template for Output PStreams.
Definition: pstream.h:494
const std::string & command() const
Return the command used to initialise the stream.
Definition: pstream.h:2091
basic_pstreambuf * open(const std::string &command, pmode mode)
Initialise the stream buffer with command.
Definition: pstream.h:1048
fd_type & rpipe()
Return the file descriptor for the active input pipe.
Definition: pstream.h:1932
istream_type & err()
Obtain a reference to the istream that reads the process' stderr.
Definition: pstream.h:894
basic_ipstream()
Default constructor, creates an uninitialised stream.
Definition: pstream.h:370
~basic_rpstream()
Destructor.
Definition: pstream.h:841
void close()
Close the pipe.
Definition: pstream.h:2071
void peof()
Close the pipe connected to the process' stdin.
Definition: pstream.h:1639
basic_opstream< char > opstream
Type definition for common template specialisation.
Definition: pstream.h:907
pbase_type::pmode pmode
Type used to specify how to connect to the process.
Definition: pstream.h:629
void open(const std::string &file, const argv_type &argv, pmode mode=pstdin)
Start a process.
Definition: pstream.h:594
int status() const
Return the exit status of the process.
Definition: pstream.h:1618
basic_pstream< char > pstream
Type definition for common template specialisation.
Definition: pstream.h:909
static const pmode pstdin
Write to stdin.
Definition: pstream.h:87
std::streamsize showmanyc()
Report how many characters can be read from active input without blocking.
Definition: pstream.h:1803
void open(const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin)
Start a process.
Definition: pstream.h:717
basic_opstream(const std::string &file, const argv_type &argv, pmode mode=pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:541
basic_opstream(const std::string &command, pmode mode=pstdin)
Constructor that initialises the stream by starting a process.
Definition: pstream.h:526
basic_pstreambuf * kill(int signal=SIGTERM)
Send a signal to the process.
Definition: pstream.h:1541
istream_type & out()
Obtain a reference to the istream that reads the process' stdout.
Definition: pstream.h:882
~basic_opstream()
Destructor.
Definition: pstream.h:566