From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17344 invoked by alias); 26 Sep 2014 20:34:47 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19169 Received: (qmail 23532 invoked from network); 26 Sep 2014 20:34:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=I1RIz/HGPkpgSQOIoiMM09GqLPVip40UoGc5z5Q+T04=; b=Ok/VQA/6hqwHBNJtEyQwDJvW7X/MaSTsZL63D797lmTSugo7ERLP3KJB5Uv25IM5h6 4NEr8DU9Zca0I176/88UItScTdWrZ0k6Md4tOTvRNUkHRLyI3XpsIHGMQoaGpeGIRWFn M/8DkiSCRtiNN3wmXeuvameYBpclyVaHp54qMyyMB10bA0NtXG2eCaXBIgNaARd4Hxl7 MnSOirwMcvPcFyW2FW66XK00Bfshqk7lXBnEndWNIehmh+kK/Z6seTvQSWy1R7jQtMA5 9IWK3/d/0eOilaXWu1E3N65S52SvbuDVNVn0kxTS4S7XQwCcsj3I2T9tQQ2AInIhB9C5 ZYww== X-Gm-Message-State: ALoCoQnucFhpD3S3xf77cvj5+ITzXSNNPi+M3DcSCcRRHp79ALTbDR8TpR2MDDMrDVs2a/bVHj5/ MIME-Version: 1.0 X-Received: by 10.60.60.131 with SMTP id h3mr23992109oer.17.1411763677372; Fri, 26 Sep 2014 13:34:37 -0700 (PDT) In-Reply-To: <87y4t66td0.fsf@thinkpad-t440p.tsdh.org> References: <87mw9qdp7s.fsf@thinkpad-t440p.tsdh.org> <20140924200710.2f764272@pws-pc.ntlworld.com> <8738bg2n1v.fsf@thinkpad-t440p.tsdh.org> <140926000448.ZM30835@torch.brasslantern.com> <878ul6lrw9.fsf@thinkpad-t440p.tsdh.org> <87y4t66td0.fsf@thinkpad-t440p.tsdh.org> Date: Fri, 26 Sep 2014 13:34:37 -0700 Message-ID: Subject: Re: ZSH history not saved anymore From: Kurtis Rader To: Tassilo Horn Cc: Zsh Users Content-Type: multipart/alternative; boundary=089e0149bb247f40260503fdd877 --089e0149bb247f40260503fdd877 Content-Type: text/plain; charset=UTF-8 The problem is the SIGPIPE. It's terminating the shell before it has a chance to handle the SIGHUP. Notice that the SIGPIPE was sent by the user process with pid 4637 running as uid 1000. I'll bet that you'll find that user ID is yours and the pid is the terminal emulator. If you look earlier in the strace output for the terminal emulator you should be able to find the kill syscall that sent the SIGPIPE. I have no idea why the emulator feels the need to send SIGPIPE -- that's a very peculiar thing to do. Obviously you can work around the problem by telling zsh to trap that signal: TRAPPIPE() { exit } On Fri, Sep 26, 2014 at 1:04 PM, Tassilo Horn wrote: > Kurtis Rader writes: > > Hi Kurtis, > > > In a different window execute one of the printed kill commands then > > > > cat /tmp/x > > Ok, I didn't rm /tmp/x in /tmp/z, so after executing the three printed > commands one after the other, the file contains: > > exiting on HUP > exiting on TERM > > > Notice that your traps for SIGHUP and SIGTERM are honored but the trap > > for SIGKILL is not. > > Indeed. > > > That's because the OS kernel ignores any handler for SIGKILL. So if > > your terminal emulator is sending SIGKILL there is nothing zsh can do. > > If that is happening you should switch to a saner terminal emulator. > > I've written a bug report, so if they really send a SIGKILL that'll > hopefully change anytime soon. > > > If you're running on a Linux based OS you should be able to trace the > > shells interaction with the OS using the strace command. Similarly you > > should be able to trace the terminal emulator to see what operating > > system calls it is making. One or both of those outputs should make it > > clear how the shell is being terminated. You may also find that it's > > being terminated with SIGHUP or SIGTERM but the attempt to write the > > history is failing (look for failed open() or write() calls). > > The last lines when closing the terminal emulator are: > > --8<---------------cut here---------------start------------->8--- > close(7) = 0 > munmap(0x7f9e899e6000, 2105616) = 0 > select(6, [5], NULL, NULL, {0, 105000}) = 0 (Timeout) > epoll_ctl(3, EPOLL_CTL_DEL, 5, 7fff4eb6e6b0) = 0 > close(5) = 0 > close(6) = 0 > rt_sigaction(SIGPIPE, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > rt_sigaction(SIGALRM, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > rt_sigaction(SIGUSR1, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > rt_sigaction(SIGUSR2, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > rt_sigaction(SIGHUP, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > rt_sigaction(SIGTERM, {SIG_DFL, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, > 0x7f9e96e7e200}, NULL, 8) = 0 > close(4) = 0 > close(3) = 0 > munmap(0x7f9e97d54000, 16384) = 0 > munmap(0x7f9e97d44000, 65536) = 0 > exit_group(0) = ? > +++ exited with 0 +++ > --8<---------------cut here---------------end--------------->8--- > > And when I do "strace -p" and then close > the other term, those are the last lines. > > --8<---------------cut here---------------start------------->8--- > getuid() = 1000 > geteuid() = 1000 > capget({_LINUX_CAPABILITY_VERSION_3, 0}, NULL) = 0 > capget({_LINUX_CAPABILITY_VERSION_3, 0}, {0, 0, 0}) = 0 > ioctl(10, FIONREAD, [0]) = 0 > ioctl(10, SNDRV_TIMER_IOCTL_SELECT or TIOCSPGRP, [4641]) = 0 > ioctl(10, SNDCTL_TMR_STOP or SNDRV_TIMER_IOCTL_GINFO or TCSETSW, {B38400 > opost isig -icanon -echo ...}) = 0 > write(10, "\r\33[0m\33[27m\33[24m\33[J\33[34m\33[1m[\33[0m"..., 267) = 267 > write(10, "\33[K", 3) = 3 > rt_sigprocmask(SIG_UNBLOCK, [WINCH], [WINCH], 8) = 0 > read(10, 0x7fff7944683f, 1) = -1 EIO (Input/output error) > --- SIGHUP {si_signo=SIGHUP, si_code=SI_KERNEL} --- > --- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=4637, si_uid=1000} > --- > +++ killed by SIGPIPE +++ > --8<---------------cut here---------------end--------------->8--- > > Hm, so it seems ZSH does receive a SIGHUP and then a SIGPIPE which I > think is the EOF Bart talked about. > > Bye, > Tassilo > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank --089e0149bb247f40260503fdd877--