--- config.h.in +++ config.h.in 2011-03-08 11:18:00.139925937 +0000 @@ -530,6 +530,9 @@ /* Define if you have the asprintf function. */ #undef HAVE_ASPRINTF +/* Define if you have the ATEXIT function. */ +#undef HAVE_ATEXIT + /* Define if you have the bcopy function. */ #undef HAVE_BCOPY --- configure +++ configure 2011-03-08 11:20:57.780426177 +0000 @@ -13497,7 +13497,7 @@ done -for ac_func in bcopy bzero confstr faccessat fnmatch \ +for ac_func in atexit bcopy bzero confstr faccessat fnmatch \ getaddrinfo gethostbyname getservbyname getservent inet_aton \ memmove pathconf putenv raise regcomp regexec \ setenv setlinebuf setlocale setvbuf siginterrupt strchr \ --- configure.in +++ configure.in 2011-03-08 11:20:46.020641745 +0000 @@ -727,7 +727,7 @@ AC_CHECK_FUNCS(dup2 eaccess fcntl getdta AC_REPLACE_FUNCS(rename) dnl checks for c library functions -AC_CHECK_FUNCS(bcopy bzero confstr faccessat fnmatch \ +AC_CHECK_FUNCS(atexit bcopy bzero confstr faccessat fnmatch \ getaddrinfo gethostbyname getservbyname getservent inet_aton \ memmove pathconf putenv raise regcomp regexec \ setenv setlinebuf setlocale setvbuf siginterrupt strchr \ --- sig.c +++ sig.c 2011-03-08 11:32:29.067927069 +0000 @@ -292,6 +292,11 @@ initialize_terminating_signals () #endif /* !HAVE_POSIX_SIGNALS */ +#if defined (HISTORY) && defined (HAVE_ATEXIT) + if (interactive_shell) + atexit(maybe_save_shell_history); +#endif /* HISTORY && HAVE_ATEXIT */ + termsigs_initialized = 1; } @@ -504,8 +509,11 @@ termsig_sighandler (sig) if (terminate_immediately) { #if defined (HISTORY) - /* XXX - will inhibit history file being written */ - history_lines_this_session = 0; +# if defined (HAVE_ATEXIT) + if (sig == SIGABRT) +# endif + /* XXX - will inhibit history file being written */ + history_lines_this_session = 0; #endif terminate_immediately = 0; termsig_handler (sig); @@ -532,10 +540,10 @@ termsig_handler (sig) if (sig == SIGINT && signal_is_trapped (SIGINT)) run_interrupt_trap (); -#if defined (HISTORY) +#if defined (HISTORY) && ! defined (HAVE_ATEXIT) if (interactive_shell && sig != SIGABRT) maybe_save_shell_history (); -#endif /* HISTORY */ +#endif /* HISTORY && ! HAVE_ATEXIT */ #if defined (JOB_CONTROL) if (sig == SIGHUP && (interactive || (subshell_environment & (SUBSHELL_COMSUB|SUBSHELL_PROCSUB))))