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
Post by Shane Brooks----- Original Message -----
Date: Wed, 10 Jul 2002 08:17:50 -0700
Subject: Re: close cygwin window - bash doesnt save history
Post by Dario AlcocerEven better solution: register a signal handler in your Bash session
for SIGHUP; the cygwin1.dll sends a hangup signal when CTRL_CLOSE_EVENT
$ 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() {
$ 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/