6

If I work in terminal, and, say run rails server in it attached to the current terminal and then close the tab it will not terminate the process making it hang around indefinitely without ability to bring it. Is it possible to fix it?

Steps to reproduce:

  1. Open new terminal tab (cmd + t);
  2. Run a process in it (e.g. irb);
  3. Close the tab (cmd + w);
  4. List processes to see that irb is still running (ps ax|grep irb).

Quitting iTerm doesn't finish these processes either.

  • If you Quit iTerm2 will it not quit all processes? – Ruskes Sep 12 '14 at 2:17
  • @Buscar웃 yes, it wouldn't quit them. I've just added steps to reproduce to question. – Andrew Sep 16 '14 at 15:41
  • Do you have tmux integration turned on? If so, it's probably creating tmux sessions for every tab you open. Try tmux list-sessions and see what it comes back with. – Jay Thompson Sep 16 '14 at 15:48
  • @JayThompson I don't use tmux, but I have it installed, list-sessions tells me failed to connect to server: No such file or directory – Andrew Sep 16 '14 at 16:15
  • Hm. Does it also happen for non-Ruby processes? e.g. top – Jay Thompson Sep 16 '14 at 16:54
3

I think it is supposed to be a feature instead of a problem.

Generally, to kill a process or just exit the current shell session, you should not use "cmd+w" or click the close button of the window. Instead, you should use "ctrl-c" and "ctrl-d" respectively.

Besides, the following facts may help you,

  • You can use "cmd+z" to fully restore a tab right after it is closed
  • The attached session and tasks keep run in background right after you close a tab. You can restore the tab at this point. But if you open a new tab using "cmd+t" now, the background session in the previously closed tab will be killed.

So the "restorable tab closing" is a feature of iterm2, though quite confusing.

  • 1
    you have only 5 seconds to undo before iterm2 kills process for real though – igor May 14 at 11:33
-2

I know its super old, but incase anyone else comes across this: Ctrl+C worked for me in iterm2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .