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

Re: ZSH history not saved anymore



Kurtis Rader <krader@xxxxxxxxxxxxx> 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<pid-of-zsh-inside-other-term>" 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



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