prevent the zombie apocalypse
This commit is contained in:
parent
4820f0da13
commit
94e8fed7c5
41
dunst.c
41
dunst.c
@ -15,6 +15,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
@ -214,19 +215,27 @@ void context_menu(void) {
|
|||||||
if (len == 0)
|
if (len == 0)
|
||||||
return;
|
return;
|
||||||
buf[len - 1] = '\0';
|
buf[len - 1] = '\0';
|
||||||
|
|
||||||
|
int status;
|
||||||
|
waitpid(pid, &status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(parent_io[0]);
|
close(parent_io[0]);
|
||||||
|
|
||||||
int browser_pid = fork();
|
int browser_pid1 = fork();
|
||||||
|
|
||||||
|
if (browser_pid1) {
|
||||||
if (browser_pid == 0) {
|
int status;
|
||||||
|
waitpid(browser_pid1, &status, 0);
|
||||||
|
} else {
|
||||||
|
int browser_pid2 = fork();
|
||||||
|
if (browser_pid2) {
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
browser = string_append(browser, buf, " ");
|
browser = string_append(browser, buf, " ");
|
||||||
char **cmd = string_to_argv(browser);
|
char **cmd = string_to_argv(browser);
|
||||||
execvp(cmd[0], cmd);
|
execvp(cmd[0], cmd);
|
||||||
} else {
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,10 +265,17 @@ void run_script(notification *n)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pid = fork();
|
int pid1 = fork();
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid1) {
|
||||||
execlp(n->script, n->script,
|
int status;
|
||||||
|
waitpid(pid1, &status, 0);
|
||||||
|
} else {
|
||||||
|
int pid2 = fork();
|
||||||
|
if (pid2) {
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
|
int ret = execlp(n->script, n->script,
|
||||||
appname,
|
appname,
|
||||||
summary,
|
summary,
|
||||||
body,
|
body,
|
||||||
@ -267,10 +283,11 @@ void run_script(notification *n)
|
|||||||
urgency,
|
urgency,
|
||||||
(char *) NULL
|
(char *) NULL
|
||||||
);
|
);
|
||||||
} else if (pid < 0) {
|
if (ret != 0) {
|
||||||
PERR("Unable to fork", errno);
|
PERR("Unable to run script", errno);
|
||||||
} else {
|
exit(EXIT_FAILURE);
|
||||||
return;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user