Introduction
Introduction Statistics Contact Development Disclaimer Help
check an error condition in fork() and print the actual execlp error - thinglau…
git clone git://bitreich.org/thinglaunch
Log
Files
Refs
Tags
LICENSE
---
commit 2c329aa6247ff532fce877debb1e80075bcbbba3
parent dfd9734eae6f1adea3f1afc84cb82beee283da84
Author: Hiltjo Posthuma <[email protected]>
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 <[email protected]>
Diffstat:
M 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, ...)
{
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.