On Tue, Mar 08, 2011 at 03:07:13PM +0100, Roman Rakus wrote: > On 03/08/2011 12:32 PM, Dr. Werner Fink wrote: > >Something like the attached patch. > > > Seems it doesn't work. I have applied your patch, run that bash in > gnome-terminal, close the terminal. In gdb I set a break to atexit() > and maybe_save_shell_history() functions. Bash receives SIGHUP, I say > continue, bash again receives SIGHUP, again continue and bash ends. > gdb is saying: Program terminated with signal SIGHUP, Hangup. > > In man page of atexit: > NOTES > Functions registered using atexit() (and on_exit(3)) are not > called if > a process terminates abnormally because of the delivery of a signal. > > so I guess it won't work.
I'm aware of this ... but here is what I see: werner/bash> xterm -e bash -l [switch over to new xterm] werner@boole:/usr/src/werner/bash> echo $BASH_VERSION 4.2.7(1)-release werner@boole:/usr/src/werner/bash> echo ooo ooo [hangup due closing xterm] werner/bash> bash werner@boole:/usr/src/werner/bash> echo ooo ... it seems to work here. If it does not work for you, you may try to add the line int maybe_append_history (char *filename) __attribute__((destructor(1))); before the definition of maybe_append_history() in bash-4.2/bashhist.c Werner -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr