From 71c9aea62a1ae9fb61ff8d8d2847edd9d07c5808 Mon Sep 17 00:00:00 2001 From: sabetts Date: Sat, 15 Sep 2001 11:35:39 +0000 Subject: (spawn): set the process group ID and session ID for the spawned process. --- src/actions.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3