Wait for children to exit, so there are no zombies left. - thingmenu - A simple graphical menu launcher for X11.
 (HTM) git clone git://bitreich.org/thingmenu
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) LICENSE
       ---
 (DIR) commit f19ef16ad6c6db0361253620088a5b37b9d0ab4d
 (DIR) parent 811e5fc9b529d6efa2833e58e9a08165490f3281
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Fri, 24 May 2019 20:19:14 +0200
       
       Wait for children to exit, so there are no zombies left.
       
       Diffstat:
         M thingmenu.c                         |      10 +++++++---
       
       1 file changed, 7 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/thingmenu.c b/thingmenu.c
       @@ -9,6 +9,8 @@
        #include <string.h>
        #include <stdlib.h>
        #include <libgen.h>
       +#include <sys/types.h>
       +#include <sys/wait.h>
        #include <X11/keysym.h>
        #include <X11/Xatom.h>
        #include <X11/Xlib.h>
       @@ -524,14 +526,13 @@ void
        runentry(Entry *e)
        {
                char *shell;
       -        int pid;
        
                if (oneshot || e->forceexit)
                        running = False;
        
       -        switch (pid = fork()) {
       +        switch (fork()) {
                case -1:
       -                return;
       +                break;
                case 0:
                        shell = getenv("SHELL");
                        if (!shell)
       @@ -539,6 +540,9 @@ runentry(Entry *e)
        
                        execlp(shell, basename(shell), "-c", e->cmd, (char *)NULL);
                        break;
       +        default:
       +                wait(NULL);
       +                break;
                }
        }