#include <utilmm/system/process.hh>
Definition of the streams we can redirect to
| utilmm::process::process |
( |
| ) |
|
| utilmm::process::~process |
( |
| ) |
|
| void utilmm::process::clear |
( |
| ) |
|
| void utilmm::process::clear_environment |
( |
| ) |
|
Remove any overriden environment variable
| std::list<std::string> utilmm::process::cmdline |
( |
| ) |
const |
Get the list of elements in the command line. It includes the process name.
| void utilmm::process::detach |
( |
| ) |
|
Detach from a running process Call this to make the process object forget about a running child.
After a call to detach(), the child process won't be stopped when this object is destroyed
| std::string utilmm::process::environment |
( |
const std::string & |
key | ) |
const |
Gets an overriden environment variable
- Parameters
-
- Returns
- the variable value if
key has previously been overriden by a call to process::set_environment
| void utilmm::process::erase_redirection |
( |
Stream |
stream | ) |
|
Removes any redirection for stream
- Parameters
-
| stream | the output stream to consider |
| bool utilmm::process::exit_normal |
( |
| ) |
const |
Check if the last running process exited normally
| int utilmm::process::exit_status |
( |
| ) |
const |
Get the exit status of the last running process
| static void utilmm::process::install_sigint_handler |
( |
| ) |
|
|
static |
| static void utilmm::process::killall |
( |
| ) |
|
|
static |
Kill all processes managed by a process instance It is safe to call this inside a signal handler
| process& utilmm::process::operator<< |
( |
std::string const & |
newarg | ) |
|
An alias to push
- See also
- push
| pid_t utilmm::process::pid |
( |
| ) |
const |
Get the PID of the last running process
| void utilmm::process::push |
( |
const std::string & |
arg | ) |
|
Add an element on the command line
| void utilmm::process::redirect_to |
( |
Stream |
stream, |
|
|
int |
handle, |
|
|
bool |
auto_close = true |
|
) |
| |
Redirects the program output to a file or an already opened file descriptor
- Using temporary files
tempfile tmp("basename");
- Make the object open a file
- Parameters
-
| stream | the output stream, either StdOut or StdErr |
| handle | the file handle to redirect to, or InvalidHandle |
| auto_close | if the file descriptor is owned by this object. If this flag is true, there is no more guarantee as to the status of the file descriptor. It can be closed anytime by the process object |
| void utilmm::process::redirect_to |
( |
Stream |
stream, |
|
|
FILE * |
handle, |
|
|
bool |
auto_close = true |
|
) |
| |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void utilmm::process::redirect_to |
( |
Stream |
stream, |
|
|
boost::filesystem::path const & |
file |
|
) |
| |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| bool utilmm::process::running |
( |
| ) |
|
Check if the process is running
| void utilmm::process::set_environment |
( |
const std::string & |
key, |
|
|
const std::string & |
value |
|
) |
| |
Override an environment variable This function sets or overrides an environment variable for the subprocess.
- Parameters
-
| key | the variable name |
| value | the variable value |
| void utilmm::process::set_pgid |
( |
pid_t |
pid | ) |
|
Set the process group ID at startup. See setpgid(3)
| void utilmm::process::set_workdir |
( |
boost::filesystem::path const & |
dir | ) |
|
Set the working directory
| void utilmm::process::signal |
( |
int |
signo = SIGINT | ) |
|
Send a signal to a running process
- signo specify the signal to send to the process
- Returns
- { true if the signal was sent successfully or if the process was not running, false otherwise. }
- Exceptions
-
| void utilmm::process::start |
( |
| ) |
|
Start the process
- Exceptions
-
| void utilmm::process::wait |
( |
| ) |
|
Wait for the process to terminate Use running() to check if the process is running or not
| boost::filesystem::path utilmm::process::workdir |
( |
| ) |
const |
Get the working directory
- Returns
- the value set by set_workdir, or an empty string
| const int utilmm::process::InvalidHandle = -1 |
|
static |
The documentation for this class was generated from the following file: