This is the mail archive of the cygwin@cygwin.com 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: close cygwin window - bash doesnt save history


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 <alcocer@helixdigital.com>
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/


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