Fix runentry to not spawn zombies. - thingmenu - A simple graphical menu launcher for X11. HTML git clone git://bitreich.org/thingmenu DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit 811e5fc9b529d6efa2833e58e9a08165490f3281 DIR parent bcb369a656d09ae2c2bb76d99622afc9ba33474b HTML Author: Christoph Lohmann <20h@r-36.net> Date: Fri, 24 May 2019 19:30:12 +0200 Fix runentry to not spawn zombies. Thanks to Platon Ryzhikov <ihummer63@yandex.ru> for reporting! Diffstat: M thingmenu.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) --- DIR diff --git a/thingmenu.c b/thingmenu.c @@ -524,21 +524,22 @@ void runentry(Entry *e) { char *shell; + int pid; - if (fork()) { - if (oneshot || e->forceexit) { - running = False; - } - return; - } - if (fork()) - exit(0); + if (oneshot || e->forceexit) + running = False; - shell = getenv("SHELL"); - if (!shell) - shell = "/bin/sh"; + switch (pid = fork()) { + case -1: + return; + case 0: + shell = getenv("SHELL"); + if (!shell) + shell = "/bin/sh"; - execlp(shell, basename(shell), "-c", e->cmd, (char *)NULL); + execlp(shell, basename(shell), "-c", e->cmd, (char *)NULL); + break; + } } void