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


On Wed, Jul 10, 2002 at 06:29:52AM -0700, Barry Buchbinder wrote:
> Solution: Don't hit the 'X' button.  Don't get out of
> bash by turn off the power, either.  Use "logout" or
> "exit".
> 
> Bash obviously does not save history after each
> command; it saves history when it shuts down.  Hitting
> the 'X' button kills it without going through the
> normal shut down sequence.

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.

P.S. BTW, I didn't know the answer to this beforehand, but instead
actually looked at the source.  That's one of the beauties of open
source projects: questions like these can be answered by direct
inspection.  "Read the Source, Luke!" ;-)

-- 
Dario Alcocer -- Sr. Software Developer, Helix Digital Inc.
alcocer@helixdigital.com -- http://www.helixdigital.com

--
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]