5

In my bindings, prefix + CTRL-Z triggers the "suspend-client" command in tmux. I've triggered this many times by mistake and I'm left with a "zombie terminal" without prompt and I can't figure out how to "wake" it.

According to the tmux man page:

suspend-client [-t target-client]
 (alias: suspendc)
 Suspend a client by sending SIGTSTP (tty stop).

Is there a "way back" or I just have to kill the terminal?

What is it used for?

1
  • 1
    After suspend-client you're left without prompt; I'm left in a shell and I can fg. This is because I prefer to keep a shell as a parent process for any tmux client. My .bashrc checks if it's not inside tmux, then runs tmux a || tmux. – Kamil Maciorowski Oct 15 '19 at 11:28
2

Lookup the tmux client pid with ps and use kill -CONT <pid>.

And yes, resume-client should be implemented for use with tmux -C.

0

SIGTSTP is canonically the signal for suspending a foreground process, and (almost) the same as ctrl+z. The obvious benefit is that this halts its use of resources and any other impact it may have; it freezes the state of the process and yields control to the parent process. The less obvious benefit is the TTY component: you immediately regain control over stdin/out/err, and when you resume the task, you either retain control of execution and I/O with bg, as if you were running it like prog &, or release it with fg (prog.) I know that SIGCONT will resume the process, but I don't know if or how it decides between FG/BG.

Now, the difference between SIGTSTP and SIGSTOP is that SIGSTOP is non-negotiable, whereas SIGTSTP can be "trapped" (handled/caught/etc.) Here is a simple example and here are a few caveats. Try man 7 signal - you may find another collision, if not a way to use them to your benefit.

There are some 'exterior' commands that perform the same role - you may be able to accomplish this with stty ixon/ixoff, but I'm not an expert and I haven't done much of anything with signals. Maybe keep a cheat sheet for when you start testing, because it seems like it would be very easy to lock up your environment.

Edit - it wasn't fully clear from your post - would disabling the default Tmux binding solve your issue?

3
  • In my case the parent is not a shell, as I have zsh+tmux as my default shell. So, when I suspend tmux with prefix+CTRL-Z it doesn't have a shell to turn back to. Yes, I could remove the binding but I was curious of what was it's purpose. Thanks. – Alechan Dec 19 '17 at 22:56
  • You could insert a screen layer. I'm not positive what the relationship is between Tmux and Screen, but Screen accomplishes the same attach/detach behavior as Tmux, while the layer of indirection would give your signals a proper target. With that said, as far as I know, the parent to your Tmux/Zsh would have to handle signals one way or another, so that's another place you could look. For what it's worth, I leave bash as my user shell and tie Tmux to my emulators so I can experiment without jeopardizing my current or next session. – John P Dec 24 '17 at 21:22
  • Oh, and if you've noticed, the command you've found is suspend-client - the server could/should still be intact. You should be able to wake the client by PID (I don't see resume-client or anything similar in Tmux, or I would recommend doing it natively instead.) – John P Dec 24 '17 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.