diff options
-rw-r--r-- | sway/commands.c | 16 | ||||
-rw-r--r-- | sway/main.c | 9 |
2 files changed, 12 insertions, 13 deletions
diff --git a/sway/commands.c b/sway/commands.c index 03c682d7..2358b9e9 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <unistd.h> | 9 | #include <unistd.h> |
10 | #include <ctype.h> | 10 | #include <ctype.h> |
11 | #include <sys/types.h> | 11 | #include <sys/types.h> |
12 | #include <sys/wait.h> | ||
12 | #include "stringop.h" | 13 | #include "stringop.h" |
13 | #include "layout.h" | 14 | #include "layout.h" |
14 | #include "focus.h" | 15 | #include "focus.h" |
@@ -190,18 +191,25 @@ static enum cmd_status cmd_exec_always(int argc, char **argv) { | |||
190 | char cmd[4096]; | 191 | char cmd[4096]; |
191 | strcpy(cmd, tmp); | 192 | strcpy(cmd, tmp); |
192 | free(tmp); | 193 | free(tmp); |
193 | |||
194 | char *args[] = {"sh", "-c", cmd, 0 }; | ||
195 | sway_log(L_DEBUG, "Executing %s", cmd); | 194 | sway_log(L_DEBUG, "Executing %s", cmd); |
196 | 195 | ||
197 | pid_t pid; | 196 | pid_t pid; |
197 | // Fork process | ||
198 | if ((pid = fork()) == 0) { | 198 | if ((pid = fork()) == 0) { |
199 | execv("/bin/sh", args); | 199 | // Fork child process again |
200 | _exit(-1); | 200 | setsid(); |
201 | if (fork() == 0) { | ||
202 | execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); | ||
203 | /* Not reached */ | ||
204 | } | ||
205 | // Close child process | ||
206 | _exit(0); | ||
201 | } else if (pid < 0) { | 207 | } else if (pid < 0) { |
202 | sway_log(L_ERROR, "exec command failed, sway could not fork"); | 208 | sway_log(L_ERROR, "exec command failed, sway could not fork"); |
203 | return CMD_FAILURE; | 209 | return CMD_FAILURE; |
204 | } | 210 | } |
211 | // cleanup child process | ||
212 | wait(0); | ||
205 | return CMD_SUCCESS; | 213 | return CMD_SUCCESS; |
206 | } | 214 | } |
207 | 215 | ||
diff --git a/sway/main.c b/sway/main.c index 66921184..de17f440 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -22,8 +22,6 @@ void sway_terminate(void) { | |||
22 | wlc_terminate(); | 22 | wlc_terminate(); |
23 | } | 23 | } |
24 | 24 | ||
25 | static void sigchld_handle(int signal); | ||
26 | |||
27 | static void wlc_log_handler(enum wlc_log_type type, const char *str) { | 25 | static void wlc_log_handler(enum wlc_log_type type, const char *str) { |
28 | if (type == WLC_LOG_ERROR) { | 26 | if (type == WLC_LOG_ERROR) { |
29 | sway_log(L_ERROR, "[wlc] %s", str); | 27 | sway_log(L_ERROR, "[wlc] %s", str); |
@@ -64,9 +62,6 @@ int main(int argc, char **argv) { | |||
64 | {0, 0, 0, 0} | 62 | {0, 0, 0, 0} |
65 | }; | 63 | }; |
66 | 64 | ||
67 | /* Signal handling */ | ||
68 | signal(SIGCHLD, sigchld_handle); | ||
69 | |||
70 | setenv("WLC_DIM", "0", 0); | 65 | setenv("WLC_DIM", "0", 0); |
71 | 66 | ||
72 | wlc_log_set_handler(wlc_log_handler); | 67 | wlc_log_set_handler(wlc_log_handler); |
@@ -153,7 +148,3 @@ int main(int argc, char **argv) { | |||
153 | return 0; | 148 | return 0; |
154 | } | 149 | } |
155 | 150 | ||
156 | void sigchld_handle(int signal) { | ||
157 | (void) signal; | ||
158 | while (waitpid((pid_t)-1, 0, WNOHANG) > 0); | ||
159 | } | ||