E-MailRelay
|
Holds the parameters and future results of a waitpid() system call. More...
#include <gnewprocess.h>
Public Member Functions | |
NewProcessWaitable () | |
Default constructor for an object where wait() does nothing and get() returns zero. More... | |
NewProcessWaitable (pid_t pid, int fd=-1) | |
Constructor taking a posix process-id and optional readable file descriptor. More... | |
NewProcessWaitable (HANDLE hprocess, HANDLE hpipe, int) | |
Constructor taking process and pipe handles. More... | |
void | assign (pid_t pid, int fd) |
Reinitialises as if constructed with the given proces-id and file descriptor. More... | |
void | assign (HANDLE hprocess, HANDLE hpipe, int) |
Reinitialises as if constructed with the given proces handle and pipe handle. More... | |
NewProcessWaitable & | wait () |
Waits for the process identified by the constructor parameter to exit. More... | |
void | waitp (std::promise< std::pair< int, std::string > >) noexcept |
Calls wait() and then sets the given promise with the get() and output() values or an exception: More... | |
int | get () const |
Returns the result of the wait() as either the process exit code or as a thrown exception. More... | |
int | get (std::nothrow_t, int exit_code_on_error=127) const noexcept |
Non-throwing overload. More... | |
std::string | output () const |
Returns the first bit of child-process output. More... | |
NewProcessWaitable (const NewProcessWaitable &)=delete | |
NewProcessWaitable (NewProcessWaitable &&)=delete | |
NewProcessWaitable & | operator= (const NewProcessWaitable &)=delete |
NewProcessWaitable & | operator= (NewProcessWaitable &&)=delete |
Holds the parameters and future results of a waitpid() system call.
The wait() method can be called from a worker thread and the results collected by the main thread using get() once the worker thread has signalled that it has finished. The signalling mechanism is outside the scope of this class (see std::promise, GNet::FutureEvent).
Definition at line 197 of file gnewprocess.h.
G::NewProcessWaitable::NewProcessWaitable | ( | ) |
Default constructor for an object where wait() does nothing and get() returns zero.
Definition at line 381 of file gnewprocess_unix.cpp.
|
explicit |
Constructor taking a posix process-id and optional readable file descriptor.
Only used by the unix implementation of G::NewProcess.
Definition at line 387 of file gnewprocess_unix.cpp.
G::NewProcessWaitable::NewProcessWaitable | ( | HANDLE | hprocess, |
HANDLE | hpipe, | ||
int | |||
) |
Constructor taking process and pipe handles.
Only used by the windows implementation of G::NewProcess.
Definition at line 595 of file gnewprocess_win32.cpp.
void G::NewProcessWaitable::assign | ( | HANDLE | hprocess, |
HANDLE | hpipe, | ||
int | |||
) |
Reinitialises as if constructed with the given proces handle and pipe handle.
Definition at line 607 of file gnewprocess_win32.cpp.
void G::NewProcessWaitable::assign | ( | pid_t | pid, |
int | fd | ||
) |
Reinitialises as if constructed with the given proces-id and file descriptor.
Definition at line 396 of file gnewprocess_unix.cpp.
int G::NewProcessWaitable::get | ( | ) | const |
Returns the result of the wait() as either the process exit code or as a thrown exception.
Typically called by the main thread after the wait() worker thread has signalled its completion. Returns zero if there is no process to wait for.
Definition at line 481 of file gnewprocess_unix.cpp.
|
noexcept |
Non-throwing overload.
Definition at line 515 of file gnewprocess_unix.cpp.
std::string G::NewProcessWaitable::output | ( | ) | const |
Returns the first bit of child-process output.
Used after get().
Definition at line 530 of file gnewprocess_unix.cpp.
G::NewProcessWaitable & G::NewProcessWaitable::wait | ( | ) |
Waits for the process identified by the constructor parameter to exit.
Returns *this. This method can be called from a separate worker thread.
Definition at line 425 of file gnewprocess_unix.cpp.
|
noexcept |
Calls wait() and then sets the given promise with the get() and output() values or an exception:
Definition at line 410 of file gnewprocess_unix.cpp.