Reputation: 420
When I attempt to exit ruby processes, namely, specs, rails console, and binding.pry
calls, there are two options: ctrl+c, ctrl+z, or if things are really stuck, open a separate tab and killall ruby
. However, when I ctrl+c the first time, the terminal outputs Exiting... Interrupt again to exit immediately.
but hangs permanently. If I ctrl+c again to force exit, it successfully exits. However, from that point on, I can no longer see what I'm typing into the shell. So if I type ls
, the line will still appear blank, but if I hit enter, it will successfully execute the ls
command.
When I ctrl+z, it manages to stop the process successfully. However, after doing this a few times, I wind up with a bunch of ruby processes running, which seem to block running new ruby processes. In this scenario, killall ruby
does nothing (nor does any derivative such as looking up by pid
). I have to open activity monitor (mac) and force quit each proc individually.
Any ideas how I managed to get myself into this/how to resolve it?
Upvotes: 0
Views: 1190
Reputation: 92306
Killing all your Ruby instances is a shotgun approach; you might hit targets you didn't intend, so I suggest to avoid it.
When your shell doesn't show what you're typing any more you need to (blindly) enter reset
to reset the terminal.
Ctrl+Z doesn't kill your process, it just get's suspended. You should get an output that tells you a job number, like:
[1] + 95295 suspended man reset
Here, 1 is the job number. You can then resume the command by typing fg %<jobnumber>
, in this example fg %1
. Or you can kill it with kill -9 %<jobnumber>
, like kill -9 %1
.
Upvotes: 2