mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
Give new wait4() another review pass
This commit is contained in:
parent
ea28f93a26
commit
b8d1377ae1
1 changed files with 5 additions and 1 deletions
|
@ -157,7 +157,7 @@ static textwindows int __proc_wait(int pid, int *wstatus, int options,
|
|||
|
||||
// check if killed or win32 error
|
||||
if (wi) {
|
||||
if (pr && --pr->waiters && pr->status == PROC_UNDEAD) {
|
||||
if (pr && !--pr->waiters && pr->status == PROC_UNDEAD) {
|
||||
__proc_free(pr);
|
||||
}
|
||||
__proc_unlock();
|
||||
|
@ -180,6 +180,10 @@ static textwindows int __proc_wait(int pid, int *wstatus, int options,
|
|||
case PROC_ALIVE:
|
||||
// exit caused by execve() reparenting
|
||||
__proc_unlock();
|
||||
if (!pr->waiters) {
|
||||
// avoid deadlock that could theoretically happen
|
||||
SetEvent(__proc.onbirth);
|
||||
}
|
||||
break;
|
||||
case PROC_ZOMBIE:
|
||||
// exit happened and we're the first to know
|
||||
|
|
Loading…
Add table
Reference in a new issue