mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Tools for managing interprocess communication (IPC)
Modules | |
Message Queues | |
Shared Memory | |
Files | |
file | processInterface.hpp |
Process interface facilities. | |
file | sharedMemSegment.hpp |
Declarations for the mxlib shared memory facility. | |
file | processInterface.cpp |
Process interface facilities. | |
file | sharedMemSegment.cpp |
Definitions for the mxlib shared memory facility. | |
Functions | |
int | mx::ipc::command_response (const char *cmd, char *resp, size_t respsz) |
Run a process and copy the output to a string. More... | |
int | mx::ipc::runCommand (int &retVal, std::vector< std::string > &commandOutput, std::vector< std::string > &commandStderr, const std::vector< std::string > &commandList) |
Runs a command (with parameters) passed in using fork/exec. More... | |
int mx::ipc::command_response | ( | const char * | cmd, |
char * | resp, | ||
size_t | respsz | ||
) |
Run a process and copy the output to a string.
Uses popen, so the attendant precautions about privileges apply.
cmd | is the command to run |
resp | is the string to copy the response to. |
respsz | is the available size of the string. |
0 | on success |
-1 | on error |
Definition at line 43 of file processInterface.cpp.
int mx::ipc::runCommand | ( | int & | retVal, |
std::vector< std::string > & | commandOutput, | ||
std::vector< std::string > & | commandStderr, | ||
const std::vector< std::string > & | commandList | ||
) |
Runs a command (with parameters) passed in using fork/exec.
A new process is fork()-ed, and the child runs execvp with command provided. The output of the process is captured in commandOutput
, and error messages in commandStderr
.
The process return value in retVal
is only meaningful if this function returns 0.
If this function returns -1, the last entry in commandStderr
will contain a message, and errno may be useful.
[out] | retVal | the return value of the process. Only meaningful if this returns 0. |
[out] | commandOutput | the output, line by line. If an error, first entry contains the message. |
[out] | commandStderr | the output of stderr. |
[in] | commandList | command to be run, with one entry per command line word |
Definition at line 71 of file processInterface.cpp.
Referenced by mx::sys::gitRepo::getGitFileState(), mx::sys::gitRepo::getGitHash(), mx::sys::gitRepo::getGitModified(), and mx::sys::gitRepo::getGitName().