Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: History bug still present in 3.0.3-test5



> I reported some while ago that zsh was failing to save history when it exits
> due to a dropped connection.
> 
> This is still happening.
> 
> To see it, run
> 
> 	xterm -e zsh -l
> 
> and then use the window manager to kill the xterm.  The $HISTFILE file will
> be truncated to zero size.

I cannot reproduce this Linux, but from the backtrace you sent earlier it
seems that the problem is that first zle notices that the input is lost and
calls zexit(), and while zexit is saving the history, zsh receives the HUP
signal.  It seems to be a kernel or xterm bug, since HUP should really come
before the input is lost.  Here is the fix.

Zoltan


*** Src/builtin.c	1997/05/06 05:12:29	3.1.2.14
--- Src/builtin.c	1997/05/11 02:59:42
***************
*** 2543,2562 ****
  void
  zexit(int val, int from_signal)
  {
      HEAPALLOC {
! 	if (isset(MONITOR)) {  /* if using job control                  */
! 	    if (!stopmsg) {
! 		scanjobs();    /* check if jobs need printing           */
! 		checkjobs();   /* check if any jobs are running/stopped */
! 		if (stopmsg) {
! 		    stopmsg = 2;
! 		    LASTALLOC_RETURN;
! 		}
! 	    } else {
! 		/* send SIGHUP to any jobs left running  */
! 		killrunjobs(from_signal);
  	    }
  	}
  	if (isset(RCS) && interact) {
  	    if (!nohistsave)
  		savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
--- 2543,2564 ----
  void
  zexit(int val, int from_signal)
  {
+     static int in_exit;
+ 
      HEAPALLOC {
! 	if (isset(MONITOR) && !stopmsg && !from_signal) {
! 	    scanjobs();    /* check if jobs need printing           */
! 	    checkjobs();   /* check if any jobs are running/stopped */
! 	    if (stopmsg) {
! 		stopmsg = 2;
! 		LASTALLOC_RETURN;
  	    }
  	}
+ 	if (in_exit++ && from_signal)
+ 	    LASTALLOC_RETURN;
+ 	if (isset(MONITOR))
+ 	    /* send SIGHUP to any jobs left running  */
+ 	    killrunjobs(from_signal);
  	if (isset(RCS) && interact) {
  	    if (!nohistsave)
  		savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);



Messages sorted by: Reverse Date, Date, Thread, Author