libassa
3.5.1
|
#include <Pipe.h>
Public Member Functions | |
Pipe () | |
A no-op constructor. More... | |
~Pipe () | |
Destructor calls close () first in an attempt to close opened pipe. More... | |
FILE * | open (const string &cmd_, const string &type_) |
Starts a subshell and feed it the string cmd_ to be executed. More... | |
int | close () |
Close the pipe. More... | |
int | kill () |
Kill subprocess with SIGTERM. More... | |
pid_t | pid () const |
Get subprocess' PID. More... | |
FILE * | fp () const |
Get pipe's standard I/O file pointer. More... | |
int | fd () const |
Get pipe's file descriptor. More... | |
Private Member Functions | |
Pipe (const Pipe &) | |
Pipe & | operator= (const Pipe &) |
Private Attributes | |
FILE * | m_fp |
A standard I/O stream descriptor. More... | |
pid_t | m_child_pid |
Supbrocess' PID. More... | |
Pipe::Pipe | ( | ) |
A no-op constructor.
Definition at line 34 of file Pipe.cpp.
References ASSA::PIPE, trace_with_mask, and ~Pipe().
Pipe::~Pipe | ( | ) |
Destructor calls close () first in an attempt to close opened pipe.
Definition at line 43 of file Pipe.cpp.
References close(), open(), ASSA::PIPE, and trace_with_mask.
Referenced by Pipe().
|
private |
int Pipe::close | ( | void | ) |
Close the pipe.
The subprocess' status is collected to ensure that the child process have finished.
Definition at line 136 of file Pipe.cpp.
References m_child_pid, m_fp, ASSA::PIPE, and trace_with_mask.
Referenced by kill(), open(), and ~Pipe().
|
inline |
|
inline |
int Pipe::kill | ( | ) |
Kill subprocess with SIGTERM.
You should most probably call close() afterwards to collect child process' status.
Definition at line 118 of file Pipe.cpp.
References ASSA::ASSAERR, close(), DL, m_child_pid, ASSA::PIPE, and trace_with_mask.
Referenced by open().
FILE * Pipe::open | ( | const string & | cmd_, |
const string & | type_ | ||
) |
Starts a subshell and feed it the string cmd_ to be executed.
The pipe is created and attached to the standard input or standard output of the subprocess, according to whether type_ is either "r" (read) or "w" (write). The other end of the pipe is returned to the calling code as a standard I/O stream, FILE, ready for buffered use with fprintf(), fscanf(), fgets, etc.
cmd_ | command to execute |
type_ | "w" for write pipe and "r" for read pipe |
Definition at line 51 of file Pipe.cpp.
References ASSA::ASSAERR, close(), DL, EL, fd(), ASSA::Fork::getChildPID(), ASSA::Fork::IGNORE_STATUS, ASSA::Fork::isChild(), kill(), ASSA::Fork::KILL_ON_EXIT, m_child_pid, m_fp, ASSA::PIPE, and trace_with_mask.
Referenced by ~Pipe().
|
inline |
|
private |
|
private |