Skip to content

Commit

Permalink
Reap zombie children on i3 start (#5909)
Browse files Browse the repository at this point in the history
One case when this might be useful is when i3 is restarted and there are
children that terminate after the previous i3 instance shut down but
before the new one set things up.

Fixes #5756
  • Loading branch information
kolayne committed May 17, 2024
1 parent 854696c commit caf5b32
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,17 @@ int main(int argc, char *argv[]) {
* when calling exit() */
atexit(i3_exit);

/* There might be children who died before we initialized the event loop,
* e.g., when restarting i3 (see #5756).
* To not carry zombie children around, raise the signal to invite libev to
* reap them.
*
* Note that there is no race condition between raising the signal below and
* entering the event loop later: the signal is just to notify libev that
* zombies might already be there. Actuall reaping will take place in the
* event loop anyway. */
(void)raise(SIGCHLD);

sd_notify(1, "READY=1");
ev_loop(main_loop, 0);

Expand Down

0 comments on commit caf5b32

Please sign in to comment.