Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill a tmux pane along with the process running on it?

Tags:

tmux

Let's say you run a command like grunt serve on a tmux pane, and you kill the pane on which the command is running. I found that the process is not killed:

ps aux | grep grunt

still shows that grunt is running even though the pane is gone. How do you kill a tmux pane along with the process(es)?

like image 502
Tomohiro Koana Avatar asked Oct 16 '15 02:10

Tomohiro Koana


People also ask

How do you kill a tmux pane?

To close a pane, first ensure that you're positioned in it. Then type "exit" or Ctrl-d. Note that there is no need for Ctrl-b in this step. Once you type "exit" or Ctrl-d in the last remaining pane, tmux will close.

Does killing tmux session kill the process?

When tmux kill-session is run, all processes inside tmux will receive SIGHUP, so they should exit gracefully on their own. Save this answer. Show activity on this post. If your process can be killed with Ctrl+c , a tmux plugin called tmux-safekill may do the trick.

How do I close a window in tmux session?

ctrl + d kills a window in linux terminal, also works in tmux.


3 Answers

To stop the program running you can close the pane by entering <C-B> x and then entering y.

like image 171
Lerner Zhang Avatar answered Nov 03 '22 01:11

Lerner Zhang


Use Ctrl + b¹, > to get a menu with this and other useful commands:

screenshot

This is what uses the Spotify plugin.

¹ Or the chosen tmux escape sequence.

Other notes and sources

tmux list-keys | grep display-menu  # 

curl cht.sh/tmux                    # Online cheatsheet
  • https://wiki.archlinux.org/title/tmux
like image 23
Pablo Bianchi Avatar answered Nov 03 '22 00:11

Pablo Bianchi


You may find the tmux-safekill plugin useful.

I wanted it to kill Ruby processes, so I had to fork the repo to add that functionality in, so I'm sure you could do the same for grunt processes if you don't get all the functionality you need from the repo directly.

like image 29
Paul Fioravanti Avatar answered Nov 02 '22 23:11

Paul Fioravanti