#include <exec.h>
Public Member Functions | |
execute () | |
C'tor. | |
~execute () | |
D'tor. | |
void | fork (void) |
Fork a child process. | |
void | clear (void) |
Reset the execute class to default values, kill the child processif one is running. | |
bool | is_child (void) |
Returns true if called by the child. | |
bool | is_parent (void) |
Returns true if called by the parent. | |
pid_t | my_pid (void) |
Returns the PID. | |
void | exit (int code=0) |
Called by the child to exit with a particular code. | |
void | reroute_stdio (void) |
Called by the child to reroute the child's stdin, stdout, and stderr to the parent. | |
pid_t | child_pid (void) |
Returns the child's PID. | |
void | signal_child (int signal_no) |
Send a signal to the child. | |
void | hup_child (void) |
Send a HUP signal to the child. | |
void | kill_child (void) |
Send a KILL signal to the child. | |
void | wait (void) |
Wait for the child to exit. | |
bool | child_started (void) const |
Returns true if the child has been started. | |
bool | child_running (void) |
Returns true if the child is running. | |
bool | child_exited (void) |
Returns true of the child has existed. | |
bool | child_exited_normally (void) |
Returns true if the child has exited normally. | |
bool | child_signaled (void) |
Returns true if the child was signaled. | |
int | child_exit_code (void) |
Return the child's exit code. | |
int | child_signal_no (void) |
If the child was signaled, return the signal number. | |
void | exec (const std::string command) |
Execute a command, rerouting stdin, stdout, and stderr to parent. | |
int | in_fd (void) |
Return a file descriptor for I/O between parent and child. | |
int | out_fd (void) |
Return a file descriptor for I/O between parent a child. | |
int | err_fd (void) |
Return a file descriptor for I/O between parent and child. | |
bool | in_ready (void) |
Check I/O for input. | |
bool | out_ready (void) |
Check I/O for output. | |
bool | err_ready (void) |
Check I/O for output. | |
bool | in_eof (void) |
Check for input EOF. | |
bool | out_eof (void) |
Check for output EOF. | |
bool | err_eof (void) |
Check for err EOF. | |
int | in_read (char *buf, const int len) |
Allow child to read input from in_fd(). | |
int | in_write (const char *buf, const int len) |
Allow parent to write output to in_fd(). | |
int | out_read (char *buf, const int len) |
Allow parent to read out_fd(). | |
int | out_write (const char *buf, const int len) |
Allow child to write to out_fd(). | |
int | err_read (char *buf, const int len) |
Allow parent to read from err_fd(). | |
int | err_write (const char *buf, const int len) |
Allow child to write to err_fd(). | |
void | print (std::ostream &out) |
Dump execute object information -- used for debugging. | |
Private Member Functions | |
pid_t | check_child_ (void) |
Check the child's status. | |
bool | check_write_ready_ (int fd) |
Return true if the file descriptor is ready to be written to. | |
bool | check_read_ready_ (int fd) |
Return true if the file descriptor has input ready to be read. | |
Private Attributes | |
int | m_fd1 [2] |
int | m_fd2 [2] |
int | m_fd3 [2] |
pid_t | m_pid |
int | m_status |
bool | m_in_eof |
bool | m_out_eof |
bool | m_err_eof |
bool | m_child_started |
Definition at line 21 of file exec.h.
|
C'tor.
Definition at line 33 of file exec.cc. References clear(). |
Here is the call graph for this function:
|
D'tor.
Definition at line 39 of file exec.cc. References clear(). |
Here is the call graph for this function:
|
Check the child's status.
Definition at line 201 of file exec.cc. References m_pid. Referenced by child_exit_code(), child_exited(), child_running(), child_signal_no(), and child_signaled(). |
|
Return true if the file descriptor has input ready to be read.
Definition at line 364 of file exec.cc. Referenced by err_ready(), in_ready(), and out_ready(). |
|
Return true if the file descriptor is ready to be written to.
Definition at line 349 of file exec.cc. Referenced by err_ready(), in_ready(), and out_ready(). |
|
Return the child's exit code.
Definition at line 261 of file exec.cc. References check_child_(). Referenced by child_exited_normally(), job_archiver::mf_do_chores(), print(), job_archiver::process(), and test10(). |
Here is the call graph for this function:
|
Returns true of the child has existed.
Definition at line 228 of file exec.cc. References check_child_(). Referenced by child_exited_normally(), child_signal_no(), print(), and test10(). |
Here is the call graph for this function:
|
Returns true if the child has exited normally.
Definition at line 238 of file exec.cc. References child_exit_code(), and child_exited(). Referenced by job_archiver::mf_do_chores(), print(), job_archiver::process(), and test10(). |
Here is the call graph for this function:
|
Returns the child's PID.
Definition at line 170 of file exec.cc. References m_pid. Referenced by job_archiver::start(). |
|
Returns true if the child is running.
Definition at line 217 of file exec.cc. References check_child_(). Referenced by clear(), job_archiver::end(), err_read(), err_write(), in_read(), in_write(), job_archiver::mf_process_rsync_io(), out_read(), out_write(), print(), job_archiver::process(), and test10(). |
Here is the call graph for this function:
|
If the child was signaled, return the signal number.
Definition at line 273 of file exec.cc. References check_child_(), and child_exited(). Referenced by job_archiver::mf_do_chores(), print(), job_archiver::process(), and test10(). |
Here is the call graph for this function:
|
Returns true if the child was signaled.
Definition at line 250 of file exec.cc. References check_child_(). Referenced by job_archiver::mf_do_chores(), print(), job_archiver::process(), and test10(). |
Here is the call graph for this function:
|
Returns true if the child has been started.
Definition at line 211 of file exec.cc. References m_child_started. Referenced by err_read(), err_write(), in_read(), in_write(), out_read(), and out_write(). |
|
Reset the execute class to default values, kill the child processif one is running.
Definition at line 46 of file exec.cc. References child_running(), is_parent(), m_child_started, m_err_eof, m_fd1, m_fd2, m_fd3, m_in_eof, m_out_eof, m_pid, and signal_child(). Referenced by job_archiver::end(), execute(), fork(), and ~execute(). |
Here is the call graph for this function:
|
Check for err EOF.
Definition at line 464 of file exec.cc. References m_err_eof. Referenced by job_archiver::mf_process_child_io(), and test10(). |
|
Return a file descriptor for I/O between parent and child. If called by the parent, a readable file descriptor is returned. If called by the child, a writeable file descriptor is returned. If reroute_stdio() was called by the child, then the returned file descriptior is the same as that used by the child for stderr. Definition at line 336 of file exec.cc. References is_parent(), and m_fd3. Referenced by err_read(), err_ready(), err_write(), job_archiver::mf_process_rsync_io(), print(), and test10(). |
Here is the call graph for this function:
|
Allow parent to read from err_fd().
Definition at line 538 of file exec.cc. References child_running(), child_started(), err_fd(), and m_err_eof. Referenced by job_archiver::mf_process_child_io(), and test10(). |
Here is the call graph for this function:
|
Check I/O for output. If called by the parent, check if output from child is ready to be read. If called by the child, check if output to parent is ready to be written to. If reroute_stdio() was called by the child, then this pipe is the same as used by the child for stderr. Definition at line 439 of file exec.cc. References check_read_ready_(), check_write_ready_(), err_fd(), and is_parent(). Referenced by job_archiver::mf_process_child_io(), job_archiver::mf_process_rsync_io(), print(), and test10(). |
Here is the call graph for this function:
|
Allow child to write to err_fd().
Definition at line 555 of file exec.cc. References child_running(), child_started(), err_fd(), and m_err_eof. |
Here is the call graph for this function:
|
Execute a command, rerouting stdin, stdout, and stderr to parent.
Definition at line 379 of file exec.cc. References exit(), fork(), is_parent(), and reroute_stdio(). Referenced by job_archiver::mf_do_chores(). |
Here is the call graph for this function:
|
Called by the child to exit with a particular code.
Definition at line 130 of file exec.cc. References is_child(). Referenced by exec(), reroute_stdio(), job_archiver::start(), and test10(). |
Here is the call graph for this function:
|
Fork a child process.
Definition at line 72 of file exec.cc. References _signal_handler(), clear(), ERROR, m_child_started, m_fd1, m_fd2, m_fd3, and m_pid. Referenced by exec(), job_archiver::start(), and test10(). |
Here is the call graph for this function:
|
Send a HUP signal to the child.
Definition at line 182 of file exec.cc. References signal_child(). |
Here is the call graph for this function:
|
Check for input EOF.
Definition at line 452 of file exec.cc. References m_in_eof. Referenced by test10(). |
|
Return a file descriptor for I/O between parent and child. If called by the parent, a writeable file descriptor is returned. If called by the child, a readable file descriptor is returned. If retroute_stdio() was called by the child, then the returned file descriptor is the same as that used by the child for stdin. Definition at line 296 of file exec.cc. References is_parent(), and m_fd1. Referenced by in_read(), in_ready(), in_write(), print(), and test10(). |
Here is the call graph for this function:
|
Allow child to read input from in_fd().
Definition at line 470 of file exec.cc. References child_running(), child_started(), in_fd(), and m_in_eof. |
Here is the call graph for this function:
|
Check I/O for input. If called by the parent, check if ready to write to child's input. If called by the child, check if input is ready to be read. If reroute_stdio() was called by the child, then this pipe is the same as used by the child for stdin. Definition at line 399 of file exec.cc. References check_read_ready_(), check_write_ready_(), in_fd(), and is_parent(). |
Here is the call graph for this function:
|
Allow parent to write output to in_fd().
Definition at line 487 of file exec.cc. References child_running(), child_started(), in_fd(), and m_in_eof. Referenced by test10(). |
Here is the call graph for this function:
|
Returns true if called by the child.
Definition at line 101 of file exec.cc. References m_pid. Referenced by exit(), is_parent(), print(), reroute_stdio(), job_archiver::start(), and test10(). |
|
Returns true if called by the parent.
Definition at line 110 of file exec.cc. References is_child(). Referenced by clear(), err_fd(), err_ready(), exec(), in_fd(), in_ready(), out_fd(), out_ready(), print(), test10(), and wait(). |
Here is the call graph for this function:
|
Send a KILL signal to the child.
Definition at line 188 of file exec.cc. References signal_child(). Referenced by job_archiver::end(), and job_archiver::mf_process_rsync_io(). |
Here is the call graph for this function:
|
Returns the PID.
Definition at line 120 of file exec.cc. References pid(). Referenced by job_archiver::clear(), and print(). |
Here is the call graph for this function:
|
Check for output EOF.
Definition at line 458 of file exec.cc. References m_out_eof. Referenced by job_archiver::mf_process_child_io(), and test10(). |
|
Return a file descriptor for I/O between parent a child. If called by the parent, a readable file descriptor is returned. If called by the child, a writable file descriptor is returned. If reroute_stdio() was called by the child, then the returned file descriptor is the same as that used by the child for stdout. Definition at line 316 of file exec.cc. References is_parent(), and m_fd2. Referenced by job_archiver::mf_process_rsync_io(), out_read(), out_ready(), out_write(), print(), and test10(). |
Here is the call graph for this function:
|
Allow parent to read out_fd().
Definition at line 504 of file exec.cc. References child_running(), child_started(), m_out_eof, and out_fd(). Referenced by job_archiver::mf_process_child_io(), and test10(). |
Here is the call graph for this function:
|
Check I/O for output. If called by the parent, check if output from child is ready to be read. If called by the child, check if output to parent is ready to be written to. If reroute_stdio() was called by the child, then this pipe is the same as used by the child for stdout. Definition at line 419 of file exec.cc. References check_read_ready_(), check_write_ready_(), is_parent(), and out_fd(). Referenced by job_archiver::mf_process_child_io(), job_archiver::mf_process_rsync_io(), print(), and test10(). |
Here is the call graph for this function:
|
Allow child to write to out_fd().
Definition at line 521 of file exec.cc. References child_running(), child_started(), m_out_eof, and out_fd(). |
Here is the call graph for this function:
|
Dump execute object information -- used for debugging.
Definition at line 572 of file exec.cc. References child_exit_code(), child_exited(), child_exited_normally(), child_running(), child_signal_no(), child_signaled(), err_fd(), err_ready(), in_fd(), in_ready(), is_child(), is_parent(), my_pid(), out_fd(), and out_ready(). Referenced by operator<<(). |
Here is the call graph for this function:
|
Called by the child to reroute the child's stdin, stdout, and stderr to the parent.
Definition at line 138 of file exec.cc. References ERROR_INSTANCE, exit(), is_child(), m_fd1, m_fd2, and m_fd3. Referenced by exec(), and job_archiver::start(). |
Here is the call graph for this function:
|
Send a signal to the child.
Definition at line 176 of file exec.cc. References m_pid. Referenced by clear(), hup_child(), and kill_child(). |
|
Wait for the child to exit.
Definition at line 194 of file exec.cc. References is_parent(). Referenced by test10(). |
Here is the call graph for this function:
|
Definition at line 82 of file exec.h. Referenced by child_started(), clear(), and fork(). |
|
Definition at line 81 of file exec.h. Referenced by clear(), err_eof(), err_read(), and err_write(). |
|
Definition at line 74 of file exec.h. Referenced by clear(), fork(), in_fd(), and reroute_stdio(). |
|
Definition at line 75 of file exec.h. Referenced by clear(), fork(), out_fd(), and reroute_stdio(). |
|
Definition at line 76 of file exec.h. Referenced by clear(), err_fd(), fork(), and reroute_stdio(). |
|
Definition at line 79 of file exec.h. Referenced by clear(), in_eof(), in_read(), and in_write(). |
|
Definition at line 80 of file exec.h. Referenced by clear(), out_eof(), out_read(), and out_write(). |
|
Definition at line 77 of file exec.h. Referenced by check_child_(), child_pid(), clear(), fork(), is_child(), and signal_child(). |
|
|