Expose IPC child process exit status
Categories
(Core :: IPC, enhancement)
Tracking
()
People
(Reporter: jld, Unassigned)
References
Details
We should have an interface for notifying users of IPC when a child process exits and what its OS-level status was. There are use cases here for crash reporting, by collecting telemetry on failed exits that aren't picked up as crashes (e.g. SIGKILL from Linux's OOM killer, early crashes where the reporter isn't initialized, etc.), and for testing.
Currently we're kind of sloppy about cleaning up child processes. Bug 1658072 will fix that on Unix (unless the fork server is used; see below), and the current work-in-progress patches have one place the exit status is seen; currently that just logs to stderr, but it could be extended to look up and run a callback, resolve a MozPromise, post an observer notification, etc.
The Windows backend is less complicated than the current situation on Unix, but looks like it would need a little refactoring.
And the fork server currently ignores process termination, which needs to be fixed; I'll file a separate bug for that.
| Reporter | ||
Comment 1•1 month ago
|
||
So here's an idea. Let ProcessExitPromise = MozPromise<ProcessExitStatus, std::monostate, false>, where ProcessExitStatus holds a base::ProcessStatus and an int (see base::WaitForProcess params) and maybe the pid. Then, GeckoChildProcessHost can create a ProcessExitPromise::Private on construction, and when the time comes, pass it to the ProcessWatcher which will resolve it with the result of WaitForProcess (or the GCPH rejects it if the process was never launched). GeckoChildProcessHost can expose a method that returns a ProcessExitPromise, which can be used at the higher levels like ContentParent. (Insert RefPtr<•> or …Holder types into the above as needed.)
That should be relatively elegant for the use case in bug 1782178 comment #1: when a preallocated process is launched, Then the exit promise with a function that checks if it was SIGKILLed, and then disconnect that promise request if/when the preallocated process becomes a real content process. Thus: a notification when a preallocated process exited via SIGKILL.
(Complication: ProcessWatcher itself will SIGKILL a process if it takes too long to shut down, on release builds, so ProcessExitStatus might need a flag to separate that case from an outside SIGKILL. But that's a minor detail.)
Description
•