(In reply to James Teh [:Jamie] from comment #1) > (In reply to Jens Stutte [:jstutte] from comment #0) > > - We are already processing such a runnable when we enqueue the shutdown message > > ... > > we can check if we are asked to shutdown with `mozilla::ipc::ProcessChild::ExpectingShutdown()` which will be true only in child processes as soon as they were `NotifiedImpendingShutdown` > > For my understanding, if we're already processing a runnable, how does NotifiedImpendingShutdown get called? Is it called on a background thread? I just want to be sure I understand what needs to be done here; i.e. whether checking ExpectingShutdown in various places is enough. Yes, it is called through the IPC I/O thread. It is actually a special message intercepted by [`MessageChannel::MaybeInterceptSpecialIOMessage`](https://searchfox.org/mozilla-central/rev/918fd22032de3a0025d6e9f4fcc8b7f625315068/ipc/glue/MessageChannel.cpp#888,916), so it bypasses all queues and the main thread.
Bug 1789231 Comment 2 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
(In reply to James Teh [:Jamie] from comment #1) > (In reply to Jens Stutte [:jstutte] from comment #0) > > - We are already processing such a runnable when we enqueue the shutdown message > > ... > > we can check if we are asked to shutdown with `mozilla::ipc::ProcessChild::ExpectingShutdown()` which will be true only in child processes as soon as they were `NotifiedImpendingShutdown` > > For my understanding, if we're already processing a runnable, how does NotifiedImpendingShutdown get called? Is it called on a background thread? I just want to be sure I understand what needs to be done here; i.e. whether checking ExpectingShutdown in various places is enough. Yes, it is called through the IPC I/O thread. It is actually a special message intercepted by [`MessageChannel::MaybeInterceptSpecialIOMessage`](https://searchfox.org/mozilla-central/rev/918fd22032de3a0025d6e9f4fcc8b7f625315068/ipc/glue/MessageChannel.cpp#888,916), so it bypasses all queues and the main thread. Edit: Updated description, thanks for the feedback.