OS X kill terminal processes
Solution 1
When you press Ctrl+z you are sending a SIGTSTP ("terminal stop" signal) to a process currently running in foreground. It causes the process to suspend its operation, however the process still remains in memory.
You can resume a suspended process with fg
(in foreground) or bg
(in background) commands.
To kill a process you need to send a SIGINT ("interrupt" signal) which you can do by pressing Ctrl+c or a SIGKILL from another process (kill -s SIGKILL <pid>
).
Why processes are not killed after closing terminal app?
They actually are killed and you are seeing a warning message that the suspended processes will be killed when you close the app.
Solution 2
Type jobs
to see a list of background processes:
[1] job1
[2] job2
Type kill %n
to kill the process, where n is the number of the process.
Related videos on Youtube
techraf
This user really prefers to keep an air of mystery about them.
Updated on September 18, 2022Comments
-
techraf over 1 year
I'm confused with closing terminal applications in OS X. Why processes are not killed after closing terminal app? For example I call python interpreter then close it with ctrl+z and when I try to close terminal it asks me about running python processes. Sorry for Russian in the screenshot but you can see 2 python processes(I called it two times).
It's very annoying especially when you are working with serial port using minicom for example. You have to kill process manually after each call. Is there a way to kill them automatically?
-
Admin over 7 yearsDo you really mean ctrl+z? I mean rather than ctrl+c? Because ctrl+z only suspends processes—it doesn’t close them or kill them. So the behavior you’re seeing is expected. That is, if you used ctrl+z, then you have processes that are still running, but just suspended (not closed or killed).
-
Admin over 7 years@sideshowbarker ctrl+c in python interpreter raises keyboard interrupt but doesn't close it
-