![]() |
Kea
1.5.0
|
Implementation of the ProcessSpawn class.
More...
Inheritance diagram for isc::util::ProcessSpawnImpl:Public Member Functions | |
| ProcessSpawnImpl (const std::string &executable, const ProcessArgs &args) | |
| Constructor. More... | |
| ~ProcessSpawnImpl () | |
| Destructor. More... | |
| void | clearState (const pid_t pid) |
| Removes the status of the process with a specified PID. More... | |
| std::string | getCommandLine () const |
| Returns full command line, including arguments, for the process. More... | |
| int | getExitStatus (const pid_t pid) const |
| Returns exit status of the process. More... | |
| bool | isAnyRunning () const |
| Checks if any of the spawned processes is still running. More... | |
| bool | isRunning (const pid_t pid) const |
| Checks if the process is still running. More... | |
| pid_t | spawn () |
| Spawn the new process. More... | |
Implementation of the ProcessSpawn class.
This pimpl idiom is used by the ProcessSpawn in this case to avoid exposing the internals of the implementation, such as custom handling of a SIGCHLD signal, and the conversion of the arguments of the executable from the STL container to the array.
This class is made noncopyable so that we don't have attempts to make multiple copies of an object. This avoid problems with multiple copies of objects for a single global resource such as the SIGCHLD signal handler. In addition making it noncopyable keeps the static check code from flagging the lack of a copy constructor as an issue.
Definition at line 52 of file process_spawn.cc.
| isc::util::ProcessSpawnImpl::ProcessSpawnImpl | ( | const std::string & | executable, |
| const ProcessArgs & | args | ||
| ) |
Constructor.
| executable | A path to the program to be executed. |
| args | Arguments for the program to be executed. |
Definition at line 149 of file process_spawn.cc.
| isc::util::ProcessSpawnImpl::~ProcessSpawnImpl | ( | ) |
Destructor.
Definition at line 169 of file process_spawn.cc.
| void isc::util::ProcessSpawnImpl::clearState | ( | const pid_t | pid | ) |
Removes the status of the process with a specified PID.
This method removes the status of the process with a specified PID. If the process is still running, the status is not removed and the exception is thrown.
| pid | A process pid. |
Definition at line 323 of file process_spawn.cc.
References isc_throw, and isRunning().
Referenced by isc::util::ProcessSpawn::clearState().
Here is the call graph for this function:| std::string isc::util::ProcessSpawnImpl::getCommandLine | ( | ) | const |
Returns full command line, including arguments, for the process.
Definition at line 181 of file process_spawn.cc.
Referenced by isc::util::ProcessSpawn::getCommandLine().
| int isc::util::ProcessSpawnImpl::getExitStatus | ( | const pid_t | pid | ) | const |
Returns exit status of the process.
If the process is still running, the previous status is returned or 0, if the process is being ran for the first time.
| pid | ID of the child process for which exit status should be returned. |
Definition at line 261 of file process_spawn.cc.
References isc_throw.
Referenced by isc::util::ProcessSpawn::getExitStatus().
| bool isc::util::ProcessSpawnImpl::isAnyRunning | ( | ) | const |
Checks if any of the spawned processes is still running.
Definition at line 250 of file process_spawn.cc.
Referenced by isc::util::ProcessSpawn::isAnyRunning().
| bool isc::util::ProcessSpawnImpl::isRunning | ( | const pid_t | pid | ) | const |
Checks if the process is still running.
| pid | ID of the child processes for which state should be checked. |
Definition at line 239 of file process_spawn.cc.
References isc_throw.
Referenced by clearState(), and isc::util::ProcessSpawn::isRunning().
| pid_t isc::util::ProcessSpawnImpl::spawn | ( | ) |
Spawn the new process.
This method forks the current process and executes the specified binary with arguments within the child process.
The child process will return EXIT_FAILURE if the method was unable to start the executable, e.g. as a result of insufficient permissions or when the executable does not exist. If the process ends successfully the EXIT_SUCCESS is returned.
| ProcessSpawnError | if forking a current process failed. |
Definition at line 196 of file process_spawn.cc.
References isc_throw.
Referenced by isc::util::ProcessSpawn::spawn().