aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikolay Nechaev <nikolay_nechaev@mail.ru>2024-05-17 19:49:54 +0000
committerGitHub <noreply@github.com>2024-05-17 21:49:54 +0200
commitcaf5b32d5cb71f2ac42471aa60f3d5d281e08335 (patch)
treec3a03bd8f8c73fc9ba9dd8980459da0f6c9bd617 /src
parent854696cfb50d759549720bd117f894158a5b759d (diff)
downloadi3-caf5b32d5cb71f2ac42471aa60f3d5d281e08335.tar.gz
i3-caf5b32d5cb71f2ac42471aa60f3d5d281e08335.zip
Reap zombie children on i3 start (#5909)
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
Diffstat (limited to 'src')
-rw-r--r--src/main.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index a7fdc79e..013b82eb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);