Open Bug 1883790 Opened 2 years ago Updated 1 year ago

zombiecheck doesn't work at all on Unix

Categories

(Testing :: Mochitest, defect, P2)

defect

Tracking

(Not tracked)

People

(Reporter: jld, Unassigned)

References

Details

I could be missing something, but I don't think checkForZombies / isPidAlive has ever worked on Unix. The key problem is this call to waitpid — the wait* family of calls can be used only a process's own direct children, otherwise they will fail with ECHILD. But this code is used for processes launched by Firefox, which are never child processes of this Python script (their parent process is the Firefox parent process or the fork server, and if they're still running when their parent exits, they are reparented to pid 1). To go through the possible cases:

  • If the process doesn't exist, the kill(pid, 0) call fails with ESRCH, and isPidAlive returns false.
  • If the process is running, kill succeeds with no effect and then waitpid fails with ECHILD, so isPidAlive returns false.
  • If the process is a zombie (exited but not yet waited by its parent), it's the same as for a running process.
  • If the process is owned by another user (unlikely, especially in a container; would require pid allocation to wrap so an unrelated process gets the same pid) then it will throw an exception (when kill(pid, 0) fails with EPERM).

In particular, it will never return true; that could only happen with a direct child process that hasn't exited.

As far as solutions: on Linux there's information in procfs (/proc/{pid}/stat for basic information like zombie-vs-not, /proc/{pid}/status for more info, and /proc/{pid}/cmdline to identify the process) but that won't help on macOS. I notice that an earlier version of the patch in bug 523208 parsed the output of ps, and that may be the only portable way to get information beyond whether a process exists.

The severity field is not set for this bug.
:jmaher, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jmaher)

this seems like it is something we should do, yet it seems like everytime we fiddle with the linux OS or try to do something smart with our tooling, it turns into a much bigger project.

Severity: -- → S2
Flags: needinfo?(jmaher)
Priority: -- → P2
You need to log in before you can comment on or make changes to this bug.