1

I use tmux and my shell is zsh with a variety of Oh-my-zsh customization. Lately I have started to experience the terminal abruptly closing when finishing executing a program such as git log showing in less and other things. i've seen it while running multiple programs so it seems liable to be the shell itself, but there is no way to be sure.

So, I am wondering about a practical way to configure the shell for it to produce log files about what it is doing and maybe then I can see some information about what leads up to the crash. Maybe configure core dumps or something and use GDB on them.

Just feel sort of lost here about where to start because zsh has always been really really solid for me for years.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Steven Lu
  • 2,175
  • 3
  • 24
  • 37
  • For now I have done this `rm ~/.zsh_history` and am testing if it keeps happening. – Steven Lu Apr 06 '17 at 06:53
  • did you try `set -o xtrace` ? in this mode zsh gives alot of info which can be useful for debugging – the_velour_fog Apr 06 '17 at 06:56
  • It seems that `set -o xtrace` is similar to `set -x`? If i can set this up such that this stream is silently directed to files in all of the zsh's i spawn, then yes that should help a lot. But it probably is getting emitted on stdout so it will get munged quite heavily... See [here](http://unix.stackexchange.com/q/336576/12497) – Steven Lu Apr 06 '17 at 06:58
  • I guess what I can do is... use xtrace, deal with the absurdly huge output, while doing so also set it up in zshrc (somehow) to `tee` all this output to pid-indexed log files. That way I can still have a hope of being able to continue on my way of running things (albeit with epic zsh xtrace output interspersed) and still being able to see whatever is landing on stderr... Then once I witness the event, I have all the logs. Just kinda hoping for something less terrible. – Steven Lu Apr 06 '17 at 07:02
  • I was thinking i should just enable core dumps for zsh.. just not sure how to do it – Steven Lu Apr 06 '17 at 07:03
  • Another way would be to simply start with a default, stripped back `~/.zshrc` then just start adding things back in one by one. if it is some zsh config issue, when you add the config or oh-my-zsh thing responsible you may be able to pinpoint it that way – the_velour_fog Apr 06 '17 at 07:07
  • That's nice in theory but not practical with this kind of heisenbug. It's good advice though. The thing that is strange is that I did not touch my zsh configuration at all. – Steven Lu Apr 06 '17 at 07:08
  • To get core dumps, you can run `ulimit -c unlimited`, then start a subsidiary `zsh` and try to get it to crash. When it does, you will be left in the parent shell and hopefully have a core file to examine. The other benefit of this is that if `zsh` prints out any messages as it crashes, you'll be able to see them. – Nate Eldredge Apr 08 '17 at 03:05
  • Thanks. Hopefully once I do that i'll get a hint as to the nature of what zsh is getting itself into. I have since caught it, by just starting to spawn my shells by calling `zsh; echo 'EXITED!!!!!!!!!!'` and watching for it. There are no errors getting spat out, though it does confirm that the zsh process is silently closing. Meaning that it is not tmux or its pty management that is misbehaving. I've also added a tmux `bind -n C-d` bind that gives me a y/n prompt prior to sending a Ctrl+D through, so that character causing the shell to exit due to my fat fingers is not a factor. – Steven Lu Apr 10 '17 at 03:08
  • I tried and no coredump file got created :( – Steven Lu Apr 10 '17 at 05:20
  • Now i have reverted my oh-my-zsh pull from a few days ago. almost certain something in this causes the problem. – Steven Lu Apr 10 '17 at 05:53
  • or jump ship to prezto – Steven Lu Apr 10 '17 at 06:00
  • I have not experienced this again. it seems to have gone away once I've pegged to a commit. This strongly indicates an oh-my-zsh related problem and I'll need to check it sometime. Chances are that it's since been fixed. – Steven Lu May 20 '17 at 16:35
  • Since the problem is gone, can you please close the question? – Marlon Richert Aug 14 '20 at 17:12

0 Answers0