[*] Do you see why Zombie processes are still an issue under UNIX?
This commit is contained in:
parent
8cbceae272
commit
311b13bc32
@ -22,7 +22,7 @@ namespace Aurora::Processes
|
||||
{
|
||||
struct ProcessImpl;
|
||||
|
||||
static AuThreadPrimitives::SpinLock gSpinLock;
|
||||
static AuThreadPrimitives::RWLockUnique_t gRWLock;
|
||||
static AuHashMap<pid_t, ProcessImpl *> gPidLookupMap;
|
||||
|
||||
ProcessImpl::ProcessImpl(const StartupParmaters ¶ms) : startup_(params)
|
||||
@ -53,7 +53,7 @@ namespace Aurora::Processes
|
||||
}
|
||||
|
||||
{
|
||||
AU_LOCK_GUARD(gSpinLock);
|
||||
AU_LOCK_GUARD(gRWLock->AsWritable());
|
||||
|
||||
if (this->alive_)
|
||||
{
|
||||
@ -96,7 +96,7 @@ namespace Aurora::Processes
|
||||
|
||||
bool ProcessImpl::TryKill()
|
||||
{
|
||||
AU_LOCK_GUARD(gSpinLock);
|
||||
AU_LOCK_GUARD(gRWLock->AsReadable());
|
||||
|
||||
if (this->alive_)
|
||||
{
|
||||
@ -108,7 +108,7 @@ namespace Aurora::Processes
|
||||
|
||||
bool ProcessImpl::Terminate()
|
||||
{
|
||||
AU_LOCK_GUARD(gSpinLock);
|
||||
AU_LOCK_GUARD(gRWLock->AsReadable());
|
||||
|
||||
if (this->alive_)
|
||||
{
|
||||
@ -246,7 +246,7 @@ namespace Aurora::Processes
|
||||
}
|
||||
|
||||
{
|
||||
AU_LOCK_GUARD(gSpinLock);
|
||||
AU_LOCK_GUARD(gSpinLock->AsWritable());
|
||||
AuTryInsert(gPidLookupMap, getpid(), this);
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ namespace Aurora::Processes
|
||||
|
||||
static void HandleChildTermiantion(pid_t pid, int code)
|
||||
{
|
||||
AU_LOCK_GUARD(gSpinLock);
|
||||
AU_LOCK_GUARD(gRWLock->AsReadable());
|
||||
|
||||
auto handler = gPidLookupMap.find(pid);
|
||||
if (handler == gPidLookupMap.end()) return;
|
||||
@ -307,8 +307,6 @@ namespace Aurora::Processes
|
||||
auto process = *handler;
|
||||
process.second->ByeLol(code);
|
||||
}
|
||||
|
||||
gPidLookupMap.erase(handler);
|
||||
}
|
||||
|
||||
static void SigChldHandler(int)
|
||||
@ -333,10 +331,11 @@ namespace Aurora::Processes
|
||||
void InitUnix()
|
||||
{
|
||||
signal(SIGCHLD, SigChldHandler);
|
||||
gRWLock = AuThreadPrimitives::RWLockUnique();
|
||||
}
|
||||
|
||||
void DeinitUnix()
|
||||
{
|
||||
|
||||
gRWLock.reset();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user