Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7d7ed0e authored by Bart Van Assche's avatar Bart Van Assche
Browse files

init: Document that ReapOneProcess() does not modify 'pid'



It is essential for correct operation of ReapAnyOutstandingChildren()
that ReapOneProcess() does not modify 'pid'. Make it easier to verify
for humans that ReapOneProcess() does not modify the 'pid' local
variable. Document the value of siginfo.si_signo with DCHECK_EQ()
statements.

Bug: 213617178
Change-Id: I14baaa7adbe5416b7f777f32fb76896f2ae27b4e
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent 1b2d4436
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -53,8 +53,13 @@ static pid_t ReapOneProcess() {
        return 0;
    }

    auto pid = siginfo.si_pid;
    if (pid == 0) return 0;
    const pid_t pid = siginfo.si_pid;
    if (pid == 0) {
        DCHECK_EQ(siginfo.si_signo, 0);
        return 0;
    }

    DCHECK_EQ(siginfo.si_signo, SIGCHLD);

    // At this point we know we have a zombie pid, so we use this scopeguard to reap the pid
    // whenever the function returns from this point forward.