mirror of
https://github.com/swaywm/sway.git
synced 2024-11-13 14:04:11 +01:00
Merge pull request #2120 from martinetd/swayidle-zombies
Swayidle: doublefork to not leave zombies around
This commit is contained in:
commit
231c72a141
@ -73,7 +73,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
// cleanup child process
|
// cleanup child process
|
||||||
wait(0);
|
waitpid(pid, NULL, 0);
|
||||||
if (*child > 0) {
|
if (*child > 0) {
|
||||||
wlr_log(L_DEBUG, "Child process created with pid %d", *child);
|
wlr_log(L_DEBUG, "Child process created with pid %d", *child);
|
||||||
// TODO: add PID to active workspace
|
// TODO: add PID to active workspace
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wayland-client-protocol.h>
|
#include <wayland-client-protocol.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
@ -59,13 +60,25 @@ static void cmd_exec(void *data) {
|
|||||||
}
|
}
|
||||||
char *param = (char *)data;
|
char *param = (char *)data;
|
||||||
wlr_log(L_DEBUG, "Cmd exec %s", param);
|
wlr_log(L_DEBUG, "Cmd exec %s", param);
|
||||||
int pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
char *const cmd[] = { "sh", "-c", param, NULL, };
|
pid = fork();
|
||||||
execvp(cmd[0], cmd);
|
if (pid == 0) {
|
||||||
exit(1);
|
char *const cmd[] = { "sh", "-c", param, NULL, };
|
||||||
|
execvp(cmd[0], cmd);
|
||||||
|
wlr_log_errno(L_ERROR, "execve failed!");
|
||||||
|
exit(1);
|
||||||
|
} else if (pid < 0) {
|
||||||
|
wlr_log_errno(L_ERROR, "fork failed");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
} else if (pid < 0) {
|
||||||
|
wlr_log_errno(L_ERROR, "fork failed");
|
||||||
|
} else {
|
||||||
|
wlr_log(L_DEBUG, "Spawned process %s", param);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Spawned process %d", pid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SWAY_IDLE_HAS_SYSTEMD) || defined(SWAY_IDLE_HAS_ELOGIND)
|
#if defined(SWAY_IDLE_HAS_SYSTEMD) || defined(SWAY_IDLE_HAS_ELOGIND)
|
||||||
|
Loading…
Reference in New Issue
Block a user