summaryrefslogtreecommitdiff
path: root/src/actions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/actions.c b/src/actions.c
index c963a1a..41d0149 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -857,18 +857,21 @@ spawn(void *data)
* ugly dance to avoid leaving zombies. Could use SIGCHLD,
* but it's not very portable.
*/
- if (fork() == 0) {
- if (fork() == 0) {
- putenv(DisplayString(dpy));
- execl("/bin/sh", "sh", "-c", cmd, 0);
-
- PRINT_ERROR ("exec '%s' ", cmd);
- perror(" failed");
-
- exit(EXIT_FAILURE);
+ if (fork() == 0)
+ {
+ if (fork() == 0)
+ {
+ /* Some process setup to make sure the spawned process runs
+ in its own session. */
+ putenv(DisplayString(dpy));
+ setsid();
+ setpgid (0, 0);
+
+ execl("/bin/sh", "sh", "-c", cmd, 0);
+ _exit(EXIT_FAILURE);
+ }
+ _exit(EXIT_SUCCESS);
}
- exit(0);
- }
wait((int *) 0);
PRINT_DEBUG ("spawned %s\n", cmd);
}