summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-09-15 11:35:39 +0000
committersabetts <sabetts>2001-09-15 11:35:39 +0000
commit71c9aea62a1ae9fb61ff8d8d2847edd9d07c5808 (patch)
treef7d9690bde14c4d9194511d6e061d607f2b4c235 /src
parent7365818ca4f2207d97a22e666a1f16c2cd2baedd (diff)
downloadratpoison-71c9aea62a1ae9fb61ff8d8d2847edd9d07c5808.zip
(spawn): set the process group ID and session ID
for the spawned process.
Diffstat (limited to 'src')
-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);
}