Skip to content

Commit

Permalink
spawn/PidfdEvent: translate si_status to a wait() wstatus
Browse files Browse the repository at this point in the history
This fixes a regression that was caused by the pidfd/waitid()
transition: since then, the "status" was really the exit status and
not the bit field that could be used with
WIFEXITED()/WIFEXITEDWIFSIGNALED() etc.
  • Loading branch information
MaxKellermann committed Nov 17, 2023
1 parent d5d7e05 commit e6a30cb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/spawn/PidfdEvent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ PidfdEvent::OnPidfdReady(unsigned) noexcept
if (info.si_pid == 0)
return;

int status = W_EXITCODE(info.si_status, 0);

switch (info.si_code) {
case CLD_EXITED:
if (info.si_status == 0)
Expand All @@ -83,11 +85,15 @@ PidfdEvent::OnPidfdReady(unsigned) noexcept
break;

case CLD_KILLED:
status = W_STOPCODE(info.si_status);

logger(info.si_status == SIGTERM ? 4 : 1,
"died from signal ", info.si_status);
break;

case CLD_DUMPED:
status = W_STOPCODE(info.si_status) | WCOREFLAG;

logger(1, "died from signal ", info.si_status,
" (core dumped)");
break;
Expand All @@ -114,7 +120,7 @@ PidfdEvent::OnPidfdReady(unsigned) noexcept

event.Close();

listener->OnChildProcessExit(info.si_status);
listener->OnChildProcessExit(status);
}

bool
Expand Down

0 comments on commit e6a30cb

Please sign in to comment.