From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15062 invoked by alias); 11 Jul 2002 15:47:44 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 15055 invoked from network); 11 Jul 2002 15:47:44 -0000 Received: from unknown (HELO darius.concentric.net) (207.155.198.79) by sources.redhat.com with SMTP; 11 Jul 2002 15:47:44 -0000 Received: from mcfeely.concentric.net (mcfeely.concentric.net [207.155.198.83]) by darius.concentric.net [Concentric SMTP Routing 1.0] id g6BFlgN16972 ; Thu, 11 Jul 2002 11:47:43 -0400 (EDT) Received: from Clemens.cris.com (da003d0542.sjc-ca.osd.concentric.net [64.1.2.31]) by mcfeely.concentric.net (8.9.1a) id LAA26690; Thu, 11 Jul 2002 11:47:40 -0400 (EDT) Message-Id: <5.1.0.14.2.20020711082822.02b8e770@pop3.cris.com> X-Sender: rrschulz@pop3.cris.com Date: Thu, 11 Jul 2002 09:11:00 -0000 To: "Shane Brooks" , Dario Alcocer , cygwin@cygwin.com From: Randall R Schulz Subject: Re: close cygwin window - bash doesnt save history In-Reply-To: <20020711062601.15635.qmail@email.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-SW-Source: 2002-07/txt/msg00945.txt.bz2 Shane, Dario, I was happy to see this suggestion. I'm going to begin using it immediately. As to those who suggested "don't do that," I have to say ordinarily I avoid the close box exactly because I lose my history, but accidents (mis-clicks) happen--sometimes when I really want what's in the as-yet unsaved history (crashes happen then, too...). First, Shane, this does exactly what you want, if I understand you correctly. As you say, put it in you ".bash_profile" or ".login" (whichever you use or prefer to use). I recommend that you do _not_ put it in you .bashrc, since that will apply to all invocations of BASH, not just the top-level "login" ones. You may need to use the "--login" option when invoking the top-level bash, to make sure it sources your ".login" file. You should read the BASH manual about the exact details of startup processing and how the various options (--login, -i, etc.) and the presence of the various pertinent files interact. It's kind of messy, if you ask me, though of course you did not... Dario, in investigating why Shane might not be having success with your technique, I tried it both with and without the presence of the "tty" option in the CYGWIN environment variable. (Without is my preferred operating mode.) I discovered that the SIGHUP handler is _not invoked_ when the "tty" option _is_ used. (My hypothesis had been the opposite, actually.) I assume this means that the SIGHUP itself is not delivered when the close box is clicked and "tty" mode is in effect. By the way, I did this testing with BASH running in a "console" (character subsystem) window, not RXVT. I don't know if this is a bug or intended behavior, but it is what I see with the latest Cygwin: CYGWIN_NT-5.0 CLEMENS 1.3.12(0.54/3/2) 2002-07-06 02:16 i686 unknown Randall Schulz Mountain View, CA USA At 23:26 2002-07-10, Shane Brooks wrote: >----- Original Message ----- >From: Dario Alcocer >Date: Wed, 10 Jul 2002 08:17:50 -0700 >To: cygwin@cygwin.com >Subject: Re: close cygwin window - bash doesnt save history > > > Even better solution: register a signal handler in your Bash session > > for SIGHUP; the cygwin1.dll sends a hangup signal when CTRL_CLOSE_EVENT > > is received. Something like this: > > > > $ myclosefn() { > > echo "My close func got called." > $HOME/myclosefn.txt > > # TODO: add more clean-up logic here > > } > > $ trap myclosefn SIGHUP > > > > I've tested this, so I know it works. > > sounds great but perhaps I dont understand the answer - I'm not a > programmer or unix boy. I tried typing the following in a bash session > but it didnt execute the exit statement when I closed the window. > >$ myclosefn() { > > exit > > } > >$ trap myclosefn SIGHUP > >I guess Im hoping to find something I can put in my profile or bashrc that >will behave as above to automagically perform the "exit" and save the history. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/