1

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).

OS X terminal screenshot

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?

2
  • Do 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). Commented Aug 16, 2016 at 1:19
  • @sideshowbarker ctrl+c in python interpreter raises keyboard interrupt but doesn't close it
    – Long Smith
    Commented Aug 16, 2016 at 1:21

3 Answers 3

3

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.

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.

0

To exit fully of your Python interpreter, use ctl+D.

ctl+D means: end of input file for the Python interpreter and for most Unix commands reading from standard input.

Your Python interpreters won't be left running, and you won't have anymore useless warning from Terminal.

You must log in to answer this question.

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