Support adding a "pending callback" to the main loop, that will be
called once after all the pending events are processed. This can be
e.g. to defer destroying the process instance until its exit is fully
processed, as suggested in D127500.
Sponsored by: The FreeBSD Foundation