mirror of
https://github.com/vale981/bspwm
synced 2025-03-06 02:01:42 -05:00
Fork two times to avoid generating zombies
This commit is contained in:
parent
4451d8f0e7
commit
d9face09c9
1 changed files with 11 additions and 6 deletions
17
rule.c
17
rule.c
|
@ -25,6 +25,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include "bspwm.h"
|
#include "bspwm.h"
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
@ -141,16 +142,20 @@ bool schedule_rules(xcb_window_t win, rule_consequence_t *csq)
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
if (dpy != NULL)
|
if (dpy != NULL)
|
||||||
close(xcb_get_file_descriptor(dpy));
|
close(xcb_get_file_descriptor(dpy));
|
||||||
dup2(fds[1], 1);
|
if (fork() == 0) {
|
||||||
close(fds[0]);
|
dup2(fds[1], 1);
|
||||||
char wid[SMALEN];
|
close(fds[0]);
|
||||||
snprintf(wid, sizeof(wid), "%i", win);
|
char wid[SMALEN];
|
||||||
execl(rule_command, rule_command, wid, NULL);
|
snprintf(wid, sizeof(wid), "%i", win);
|
||||||
err("Couldn't spawn rule command.\n");
|
execl(rule_command, rule_command, wid, NULL);
|
||||||
|
err("Couldn't spawn rule command.\n");
|
||||||
|
}
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
} else if (pid > 0) {
|
} else if (pid > 0) {
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
pending_rule_t *pr = make_pending_rule(fds[0], win, csq);
|
pending_rule_t *pr = make_pending_rule(fds[0], win, csq);
|
||||||
add_pending_rule(pr);
|
add_pending_rule(pr);
|
||||||
|
wait(NULL);
|
||||||
}
|
}
|
||||||
return (pid != -1);
|
return (pid != -1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue