vector<string>& args,
44 const string& std_in,
58max_time = timeout->
sec+ timeout->
usec/ 1000000.0;
69 size_ttotal_bytes_written = 0;
70 boolout_done =
false;
71 boolerr_done =
false;
73 const size_tbuf_size = 4096;
76 while(!out_done || !err_done) {
79 if(total_bytes_written < std_in.size()) {
80pipe.
Write(std_in.c_str() + total_bytes_written,
81std_in.size() - total_bytes_written,
83total_bytes_written += bytes_written;
84 if(total_bytes_written == std_in.size()) {
94rstatus = pipe.
Read(
buf, buf_size, &bytes_read);
95std_out.append(
buf, bytes_read);
104std_err.append(
buf, bytes_read);
120pipe.
Close(&exit_value);
static int Exec(const string &cmd, const vector< string > &args, const string &std_in, string &std_out, string &std_err, STimeout *timeout=0)
Run an executable using strings for std* .
EIO_Status Write(const void *data, size_t count, size_t *written=0)
Write data to pipe (data always goes to the child's eStdIn handle).
EIO_Status Open(const string &cmd, const vector< string > &args, TCreateFlags create_flags=0, const string ¤t_dir=kEmptyStr, const char *const envp[]=0, size_t pipe_size=0)
Open pipe.
EIO_Status SetTimeout(EIO_Event event, const STimeout *timeout)
Specify timeout for the pipe I/O.
EIO_Status Read(void *buf, size_t count, size_t *read=0, EChildIOHandle from_handle=eDefault)
Read data from the pipe's default read handle.
EIO_Status CloseHandle(EChildIOHandle handle)
Close the specified child's pipe handle (even for CPipe opened with OpenSelf()).
EIO_Status Close(int *exitcode=0)
Close pipe.
@ fStdErr_Open
Do open child's stderr.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
void Start(void)
Start the timer.
unsigned int usec
microseconds (modulo 1,000,000)
@ eIO_Timeout
timeout expired before any I/O succeeded
@ eIO_Success
everything is fine, no error occurred
@ eIO_Open
also serves as no-event indicator in SOCK_Poll
@ eIO_Close
also serves as an error indicator in SOCK_Poll
Portable class to work with a spawned process via pipes.
Defines: CTimeFormat - storage class for time format.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4