On 3/8/11 11:12 AM, Chet Ramey wrote:

> I might be able to finesse this particular case based on the state that
> readline exports to the calling application.  

I think I was able to do that.  Try the attached patch; it works for me.
It identifies a single specific common case and allows the history to be
saved in that case.  I think that case minimizes the chances of deadlock,
but it requires much more testing before I will be convinced.  Please help
me out by testing it.

Yes, I know that it's not 100% safe and will run unsafe functions from a
signal handler.  I will devise a better fix for later, but that will
require changes to readline (so it can catch SIGHUP) that will have to
wait.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.2-patched/sig.c   Tue Nov 23 08:21:22 2010
--- sig.c       Tue Mar  8 21:28:32 2011
***************
*** 47,50 ****
--- 47,51 ----
  #if defined (READLINE)
  #  include "bashline.h"
+ #  include <readline/readline.h>
  #endif
  
***************
*** 63,66 ****
--- 64,68 ----
  extern int history_lines_this_session;
  #endif
+ extern int no_line_editing;
  
  extern void initialize_siglist ();
***************
*** 506,510 ****
  #if defined (HISTORY)
        /* XXX - will inhibit history file being written */
!       history_lines_this_session = 0;
  #endif
        terminate_immediately = 0;
--- 508,515 ----
  #if defined (HISTORY)
        /* XXX - will inhibit history file being written */
! #  if defined (READLINE)
!       if (interactive_shell == 0 || interactive == 0 || (sig != SIGHUP && sig 
!= SIGTERM) || no_line_editing || (RL_ISSTATE (RL_STATE_READCMD) == 0))
! #  endif
!         history_lines_this_session = 0;
  #endif
        terminate_immediately = 0;

Reply via email to