mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +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
|
// check if killed or win32 error
|
||||||
if (wi) {
|
if (wi) {
|
||||||
if (pr && --pr->waiters && pr->status == PROC_UNDEAD) {
|
if (pr && !--pr->waiters && pr->status == PROC_UNDEAD) {
|
||||||
__proc_free(pr);
|
__proc_free(pr);
|
||||||
}
|
}
|
||||||
__proc_unlock();
|
__proc_unlock();
|
||||||
|
@ -180,6 +180,10 @@ static textwindows int __proc_wait(int pid, int *wstatus, int options,
|
||||||
case PROC_ALIVE:
|
case PROC_ALIVE:
|
||||||
// exit caused by execve() reparenting
|
// exit caused by execve() reparenting
|
||||||
__proc_unlock();
|
__proc_unlock();
|
||||||
|
if (!pr->waiters) {
|
||||||
|
// avoid deadlock that could theoretically happen
|
||||||
|
SetEvent(__proc.onbirth);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PROC_ZOMBIE:
|
case PROC_ZOMBIE:
|
||||||
// exit happened and we're the first to know
|
// exit happened and we're the first to know
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue