delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/12/06/21:59:22

X-Spam-Check-By: sourceware.org
Message-ID: <457782E0.80103@cwilson.fastmail.fm>
Date: Wed, 06 Dec 2006 21:56:32 -0500
From: Charles Wilson <cygwin AT cwilson DOT fastmail DOT fm>
User-Agent: Thunderbird 1.5.0.8 (Windows/20061025)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Bash process remains after I close rxvt in certain ways
References: <ej7u2n$mgb$1 AT sea DOT gmane DOT org> <45586C29 DOT 4050805 AT byu DOT net> <45588A58 DOT 3080704 AT cwilson DOT fastmail DOT fm> <loom DOT 20061113T161452-299 AT post DOT gmane DOT org> <20061113161012 DOT GA6263 AT trixie DOT casa DOT cgf DOT cx> <457685E6 DOT 1050202 AT cwilson DOT fastmail DOT fm> <20061206115947 DOT GN9829 AT calimero DOT vinschen DOT de>
In-Reply-To: <20061206115947.GN9829@calimero.vinschen.de>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019