Tmux kill-session and dangling processes

I’m using tmuxinator to start up a session for a project that needs several windows and panes including mysqld, redis-server, and a couple processes for our app itself, and of course my vim window for development.

This is mostly working great except when I <prefix> :kill-session, it leaves some of those processes like mysqld and redis-server running, so when I start the session up again later, it isn’t nearly as smooth because redis-server and mysqld both cry about the existing process.

Is there a way to have kill-session gracefully end the processes that are running in the various windows’ panes?

Hi @jxpx777, I am not aware of any default way to do this. This Unix StackExchange answer has a good summary that talks about the signal that tmux sends to child processes, but it looks like that is not killing your processes.

You could write a small script similar to the one towards the bottom of the StackExchange question, but that looks a bit aggressive to me.

I would consider keeping your sessions alive unless you need to kill them, and if you do kill them, then manually kill the child processes first. I personally have multiple Rails apps running almost all the time. I just run them on different ports and they all peacefully coexist, so I feel no need to kill them.

Likely not the answer you wanted, but hopefully that helps.