Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Whenever I'm testing a python class I'm working on, I initiate and re-initiate python a lot to refresh the updates I make to the code. When I close the Terminal window later, I get a window that says I am about to quit a LOT of running instances of python.

enter image description here

Is this a bug on terminal's part, or am I really running all those? I Ctrl-Z out of it each time but it always says

[8]+  Stopped            Python     

where the 8 is incremental and often gets into the 20's and 30's. Am I doing something stupid?

share|improve this question
    
Hi. I will initiate it with python and exit with Ctrl-Z. –  Artur Sapek Oct 30 '11 at 0:30
    
Added how to actually quit python to my answer. –  Daniel Beck Nov 13 '11 at 12:38
    
Now don't cause a fuss dear, I'm having python, python, python, python, eggs, bash, python and python. (cue viking chorus) –  stib Dec 3 '11 at 12:43

1 Answer 1

up vote 3 down vote accepted

You're not quitting (or terminating) the program by pressing Ctrl-Z, you're suspending it. Press Ctrl-D (end of transmission) to quit Python.

And after suspending a running process, you're entering python or another intermediate launch script to "resume" the program. But this launches a separate instance of the program!

You need to enter either %n (with n being the number displayed, so e.g. %8) to resume the suspended process with job index n or fg to resume the most recently suspended process.

If you Ctrl-Z out and fg back in, the index doesn't increase either.

You are actually running tons of separate python instances. List them by entering jobs.

The man page for this is bash, as your shell manages these jobs.

share|improve this answer
    
You can also look at the Inspector to see the list of processes for the terminal. Shell > Show Inspector –  Chris Page Nov 3 '11 at 4:01
    
Just learned you can clear all past jobs with disown -a –  Artur Sapek Nov 13 '11 at 0:39
    
@artur sure if you want a ton of processes to continue running. You just disassociate them from your shell, you don't quit them. –  Daniel Beck Nov 13 '11 at 7:11
    
Oh wow okay. Any idea how to re-own them? :P –  Artur Sapek Nov 13 '11 at 18:59
    
@ArturSapek If you did disown instead of following the instructions in my post, all you can reasonably do is kill them. ps ax | grep python will show their process IDs you can then use as arguments to kill. Or, if it's a reasonably often rebooted desktop computer, just restart. –  Daniel Beck Nov 13 '11 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.