This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bash process remains after I close rxvt in certain ways


Corinna Vinschen wrote:

So there's something missing in the picture here...  What does happen in
rxvt when Alt-F4 is pressed.  Nothing?

rxvt-20050409-3 (e.g. the current version) behaves the same way in all three cases:


kill -HUP <pid of rxvt>
alt-f4 when rxvt has the focus
click on the 'x' button in the rxvt window

in each case, the current version of rxvt exits but leaves behind a zombie bash shell (assuming bash was the target cmd processor).

rxvt-20050409-4 (e.g. the test version now on the mirrors) also has a common behavior across all three cases, but that behavior is different than the behavior described above. The new rxvt exits and sighups the child (which obligingly goes ahead and dies; no zombies) in all three cases.

--
Chuck


P.S. Here's the relevant changes between -3 and -4:


src/main.c
@@ -155,6 +155,9 @@ rxvt_Exit_signal
 #ifdef DEBUG_CMD
     rxvt_print_error("signal %d", sig);
 #endif
+    // pass signal on to child cmd processor
+    rxvt_t *r = rxvt_get_r();
+    kill(r->h->cmd_pid, sig);
     rxvt_clean_exit();
     kill(getpid(), sig);
 }
@@ -200,6 +203,8 @@ rxvt_clean_exit
        r->h->Input_Context = NULL;
     }
 #endif
+    // terminal is dying, tell child cmd processor
+    kill(r->h->cmd_pid, SIGHUP);
 }


The first hunk is in the signal handler that the parent rxvt registers for SIGHUP, SIGINT, SIGQUIT, and SIGTERM -- and ensures that those signals are passed along to the child. The second hunk is in rxvt_clean_exit, which is explicitly called in some other fatal-error situations and is registered with atexit/on_exit.


Note that because rxvt_Exit_signal handler calls rxvt_clean_exit, the child may get two HUPs, or (whatever rxvt_Exit_signal got) and a HUP -- or, if rxvt_clean_exit was called via another mechanism, then the child will get only a single HUP.

It appears to work okay for me -- but I'll wait for comments on the test release before I promote it.

--
Chuck

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]