How to terminate tmux session and processes it spawned

tmux kill-session [-t session_name]

the processes in the virtual terminals should receive SIGHUP.


This was bothering me as well, so I wrote a tmux plugin for this. It's not perfect, but can easily be extended to know how to safely kill most kinds of processes before exiting tmux: tmux-safekill


Maybe it's not the most elegant solution, but does what you asked for:

tmux list-panes -s -F "#{pane_pid} #{pane_current_command}" | grep -v tmux | awk '{print $1}' | xargs kill -9

If you run this from within your tmux-session, it will kill all the processes it spawned, and you can then quit tmux with exit.

Tags:

Tmux

Byobu