summaryrefslogtreecommitdiff
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
parent7365818ca4f2207d97a22e666a1f16c2cd2baedd (diff)
downloadratpoison-71c9aea62a1ae9fb61ff8d8d2847edd9d07c5808.zip
(spawn): set the process group ID and session ID
for the spawned process.
-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);
}