summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--src/actions.c25
2 files changed, 19 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e02de2..9a0b9a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-09-14 shawn <sabetts@diggin.lamenet.tmp>
+
+ * src/actions.c (spawn): set the process group ID and session ID
+ for the spawned process.
+
2001-09-13 shawn <sabetts@diggin.lamenet.tmp>
* src/actions.c (command): Gobble the whitespace between the
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);
}