Added forget and remember functions to process library
This commit is contained in:
parent
bdb1578ba6
commit
42eca60cfc
2 changed files with 15 additions and 1 deletions
|
@ -444,6 +444,18 @@ int Util::Procs::Count() {
|
|||
/// Returns true if a process with this PID is currently active.
|
||||
bool Util::Procs::isActive(pid_t name) {
|
||||
tthread::lock_guard<tthread::mutex> guard(plistMutex);
|
||||
return (plist.count(name) == 1) && (kill(name, 0) == 0);
|
||||
return (kill(name, 0) == 0);
|
||||
}
|
||||
|
||||
/// Forget about the given PID, keeping it running on shutdown.
|
||||
void Util::Procs::forget(pid_t pid) {
|
||||
tthread::lock_guard<tthread::mutex> guard(plistMutex);
|
||||
plist.erase(pid);
|
||||
}
|
||||
|
||||
/// Remember the given PID, killing it on shutdown.
|
||||
void Util::Procs::remember(pid_t pid) {
|
||||
tthread::lock_guard<tthread::mutex> guard(plistMutex);
|
||||
plist.insert(pid);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ namespace Util {
|
|||
static int Count();
|
||||
static bool isActive(pid_t name);
|
||||
static bool isRunning(pid_t pid);
|
||||
static void forget(pid_t pid);
|
||||
static void remember(pid_t pid);
|
||||
static std::set<int> socketList; ///< Holds sockets that should be closed before forking
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue