thinglaunch

A simple command and password prompter for X11.
git clone git://r-36.net/thinglaunch
Log | Files | Refs | LICENSE

commit 2c329aa6247ff532fce877debb1e80075bcbbba3
parent dfd9734eae6f1adea3f1afc84cb82beee283da84
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat,  8 Feb 2020 16:47:51 +0100

check an error condition in fork() and print the actual execlp error

checks for -1 in fork() which can happen for example with resource process
limits. Print a clear error for fork() and execlp().

Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
thinglaunch.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/thinglaunch.c b/thinglaunch.c @@ -449,6 +449,7 @@ void execcmd(void) { char *shell; + pid_t pid; XDestroyWindow(dpy, win); @@ -463,18 +464,23 @@ execcmd(void) exit(0); } - if (fork()) - exit(0); + switch ((pid = fork())) { + case -1: + die("fork: %s\n", strerror(errno)); + case 0: + break; + default: + _exit(0); + } shell = getenv("SHELL"); if (!shell) shell = "/bin/sh"; execlp(shell, basename(shell), "-c", cbuf, (char *)NULL); - die("aiee, after exec"); + die("execlp: %s\n", strerror(errno)); } - void die(char *errstr, ...) {