From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1413 invoked from network); 11 May 1997 03:34:59 -0000 Received: from euclid.skiles.gatech.edu (root@130.207.146.50) by ns1.primenet.com.au with SMTP; 11 May 1997 03:34:59 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id XAA15736; Sat, 10 May 1997 23:11:30 -0400 (EDT) Resent-Date: Sat, 10 May 1997 23:11:30 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199705110314.XAA03760@hzoli.home> Subject: Re: History bug still present in 3.0.3-test5 In-Reply-To: <970510104024.ZM9405@candle.brasslantern.com> from Bart Schaefer at "May 10, 97 10:40:24 am" To: schaefer@candle.brasslantern.com (Bart Schaefer) Date: Sat, 10 May 1997 23:14:50 -0400 (EDT) Cc: zsh-workers@math.gatech.edu X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"BvvjP1.0.pr3.XZJTp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3115 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > 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);