aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Stevens <nilix@nilfm.cc>2022-01-18 16:29:16 -0700
committerDerek Stevens <nilix@nilfm.cc>2022-01-18 16:29:16 -0700
commitd1a8d31b45088cf96d31b86ee2e7db14d9279e02 (patch)
tree5fe923da3c91756bd81d26be7d763437cc17ae79
parent4d0f0f62daafdba27a5de4c58c925463a2eeede5 (diff)
key.c: fix zombie terminal processes
-rw-r--r--key.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/key.c b/key.c
index 42d98b4..8de96d7 100644
--- a/key.c
+++ b/key.c
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
+#include <sys/wait.h>
#include <X11/X.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
@@ -782,22 +783,28 @@ void keypress(XKeyEvent* e) {
else if (e->keycode == slcode && (e->state & SHORTCUTMOD) == (MODBITS)) {
kbLaunch = 1;
if (fork() == 0) {
- close(ConnectionNumber(dpy));
- if (dpy != '\0')
- putenv(dpy);
- signal(SIGINT, SIG_DFL);
- signal(SIGTERM, SIG_DFL);
- signal(SIGHUP, SIG_DFL);
- if (termprog != NULL) {
- execl(shell, shell, "-c", termprog, (char*)0);
- fprintf(stderr, "ryudo: exec %s", shell);
- perror(" failed");
+ if (fork() == 0) {
+ // this code doesn't seem necessary
+ // close(ConnectionNumber(dpy));
+ // if (dpy != '\0')
+ // putenv(dpy);
+ signal(SIGINT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGHUP, SIG_DFL);
+ if (termprog != NULL) {
+ execl(shell, shell, "-c", termprog, (char*)0);
+ fprintf(stderr, "ryudo: exec %s", shell);
+ perror(" failed");
+ }
+ execlp("urxvt", "urxvt", (char*)0);
+ execlp("9term", "9term", scrolling ? "-ws" : "-w", (char*)0);
+ execlp("xterm", "xterm", "-ut", (char*)0);
+ perror("ryudo: exec urxvt/9term/xterm failed");
+ exit(1);
}
- execlp("urxvt", "urxvt", (char*)0);
- execlp("9term", "9term", scrolling ? "-ws" : "-w", (char*)0);
- execlp("xterm", "xterm", "-ut", (char*)0);
- perror("ryudo: exec urxvt/9term/xterm failed");
+ exit(0);
}
+ wait((int*)0);
}
#endif