|
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. | |
Macros | |
| #define | MX_IPC_KEYLEN 1024 |
| The maximum length of the IPC key string. | |
| #define | MX_IPC_PI_BUFSZ 128 |
| The process interface buffer size. | |
Functions | |
| int | mx::ipc::command_response (const char *cmd, char *resp, size_t respsz) |
| Run a process and copy the output to a string. | |
| 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. | |
| #define MX_IPC_KEYLEN 1024 |
| #define MX_IPC_PI_BUFSZ 128 |
| 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.
References MX_IPC_PI_BUFSZ.
| 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 68 of file processInterface.cpp.
References MXE_PROCERR, mxError, and mxPError.
Referenced by mx::sys::gitRepo::getGitFileState(), mx::sys::gitRepo::getGitHash(), mx::sys::gitRepo::getGitModified(), and mx::sys::gitRepo::getGitName().