bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: History file clobbered by multiple simultaneous exits


From: Geoff Kuenning
Subject: Re: History file clobbered by multiple simultaneous exits
Date: Fri, 26 Jul 2013 21:41:15 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

> If you are using whatver `close' button your window manager provides to
> exit the shell rather than exit or ^D, it's possible that there is a signal
> race condition involved here.  Many window managers send SIGHUP/SIGKILL to
> running processes on window close.

That's pretty much what happens.  I use xinit, so when I exit it kills
the X server.  That closes the connections to the (typically 3-4)
xterms, which IIRC then send SIGHUP to their child shells.

> Bash-4.2 runs its handlers for terminating signals like SIGHUP immediately,
> interrupting whatever is in progress.  That, coupled with attempting to
> save the history from interactive shells killed this way, could result in
> zero-length files if the signals arrive at the right time.

True, but "the right time" is pretty skinny.  My typical behavior is to
type "sync" (ancient habit that I doubt I'll ever break, dating back to
the days of major unreliability) and then kill X.  The net is that all
my bash instances are idle at that point, sitting at the command
prompt.  So even if the signal handlers are calling the history-writing
code directly, life should be OK unless a second SIGHUP arrives.  (Does
bash re-enable signals when the handler gets called?  Seems unlikely,
but...)
-- 
    Geoff Kuenning   geoff@cs.hmc.edu   http://www.cs.hmc.edu/~geoff/

The "M" in XML stands for _markup_.  If you don't have anything
outside the angle brackets, you probably shouldn't be using XML.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]