diff options
author | sabetts <sabetts> | 2002-11-24 21:52:20 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2002-11-24 21:52:20 +0000 |
commit | bc15e751d3b8538720e89848db8bfb9f6f636c20 (patch) | |
tree | d192ee4116d97cdac29c2e5ee9095ab063930e23 /src/actions.c | |
parent | 1445719b28b87a3be8f13f5a931adc6fc3da9da3 (diff) | |
download | ratpoison-bc15e751d3b8538720e89848db8bfb9f6f636c20.zip |
* src/main.c: include sys/wait.h
(chld_handler): new function
* src/events.c: include sys/wait.h
(handle_signals): Print an error message in the case of a child
signal.
* src/data.h (struct rp_child_info): New struct.
(child_info): New global.
(chld_signalled): likewise
* src/actions.c (spawn): Let the SIGCHLD handler handle process
completion instead of doing an ugly dance.
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/actions.c b/src/actions.c index 2779101..d02a983 100644 --- a/src/actions.c +++ b/src/actions.c @@ -973,29 +973,27 @@ void spawn(void *data) { char *cmd = data; - /* Ugly dance to avoid leaving zombies. Could use SIGCHLD, but it's - not very portable. */ - if (fork() == 0) + int pid; + + pid = fork(); + if (pid == 0) { - if (fork() == 0) - { - /* Some process setup to make sure the spawned process runs - in its own session. */ - putenv(current_screen()->display_string); + /* Some process setup to make sure the spawned process runs + in its own session. */ + putenv(current_screen()->display_string); #ifdef HAVE_SETSID - setsid(); + setsid(); #endif #if defined (HAVE_SETPGID) - setpgid (0, 0); + setpgid (0, 0); #elif defined (HAVE_SETPGRP) - setpgrp (0, 0); + setpgrp (0, 0); #endif - execl("/bin/sh", "sh", "-c", cmd, 0); - _exit(EXIT_FAILURE); - } - _exit(EXIT_SUCCESS); + execl("/bin/sh", "sh", "-c", cmd, 0); + _exit(EXIT_FAILURE); } - wait((int *) 0); + +/* wait((int *) 0); */ PRINT_DEBUG ("spawned %s\n", cmd); } |