ifw-daq
2.1.0-pre1
IFW Data Acquisition modules
|
Represents a subprocess as an asynchronous operation. More...
#include <asyncProcess.hpp>
Public Member Functions | |
AsyncProcess (boost::asio::io_context &ctx, std::vector< std::string > args) | |
Constructor. More... | |
virtual | ~AsyncProcess () noexcept |
boost::future< int > | Initiate () override |
Starts process and asynchronous operations that read stdout and stderr. More... | |
std::optional< pid_t > | GetPid () const noexcept override |
Get PID. More... | |
std::error_code | Abort () noexcept override |
Aborts the operation by terminating process which completes the operation. More... | |
std::error_code | Signal (int sig) noexcept override |
Send signal to process. More... | |
bool | IsRunning () const noexcept override |
std::vector< std::string > const & | GetArguments () const noexcept override |
Public Member Functions inherited from daq::AsyncProcessIf | |
virtual | ~AsyncProcessIf () |
Signals | |
boost::signals2::connection | ConnectStdout (SigOutStream::slot_type const &slot) override |
Signal type for stdout/stderr signals. More... | |
boost::signals2::connection | ConnectStderr (SigOutStream::slot_type const &slot) override |
Signal type for stdout/stderr signals. More... | |
using | SigOutStream = boost::signals2::signal< void(pid_t, std::string const &)> |
Signal type for stdout/stderr signals. More... | |
Additional Inherited Members | |
Public Types inherited from daq::AsyncProcessIf | |
using | SigOutStream = boost::signals2::signal< void(pid_t, std::string const &)> |
Signal type for stdout/stderr signals. More... | |
Represents a subprocess as an asynchronous operation.
Once constructed the operation is initiated (only once) with Initiate()
which starts the process and returns a boost::future object that will receive exit code when process terminates and all output has been read.
Operation can be aborted with Abort()
which will terminate process and set future with exceptional result.
boost::process is pretty buggy so be very careful making changes to this. Examples:
on_exit
has been executed. This cause exit codes to be lost [https://github.com/boostorg/process/issues/187] Definition at line 124 of file asyncProcess.hpp.
using daq::AsyncProcessIf::SigOutStream = boost::signals2::signal<void(pid_t, std::string const&)> |
Signal type for stdout/stderr signals.
Definition at line 82 of file asyncProcess.hpp.
|
explicit |
Constructor.
ctx | io_context instance to use. |
args | Command line arguments. First argument specify the file to be executed. |
Definition at line 19 of file asyncProcess.cpp.
|
virtualnoexcept |
Definition at line 27 of file asyncProcess.cpp.
|
overridevirtualnoexcept |
Aborts the operation by terminating process which completes the operation.
If process is not running this will not do anything.
Implements daq::AsyncProcessIf.
Definition at line 62 of file asyncProcess.cpp.
|
inlineoverridevirtual |
Signal type for stdout/stderr signals.
Implements daq::AsyncProcessIf.
Definition at line 188 of file asyncProcess.hpp.
|
inlineoverridevirtual |
Signal type for stdout/stderr signals.
Implements daq::AsyncProcessIf.
Definition at line 185 of file asyncProcess.hpp.
|
inlineoverridevirtualnoexcept |
Implements daq::AsyncProcessIf.
Definition at line 176 of file asyncProcess.hpp.
|
overridevirtualnoexcept |
Get PID.
Implements daq::AsyncProcessIf.
Definition at line 72 of file asyncProcess.cpp.
|
overridevirtual |
Starts process and asynchronous operations that read stdout and stderr.
This can only be called once.
Implements daq::AsyncProcessIf.
Reimplemented in daq::RsyncAsyncProcess.
Definition at line 31 of file asyncProcess.cpp.
|
overridevirtualnoexcept |
Implements daq::AsyncProcessIf.
Definition at line 89 of file asyncProcess.cpp.
|
overridevirtualnoexcept |
Send signal to process.
Unlike Abort() this can be used to gracefully terminate application by sending e.g. SIGTERM.
sig | Signal to send. |
Implements daq::AsyncProcessIf.
Definition at line 79 of file asyncProcess.cpp.