Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a simple python game script on my server which runs a loop like:

while True :
  (( listen for packets ))
  (( send packets back to all connected clients ))

I launch this script with

./gameServer.py &

Sometimes things go weird and I end up at my terminal again (PuTTy) but the script is still apparently running when I check ps.

I tried kill 3081 (where 3081 is the process id of the gameServer.py script) but it will not die.

Should I do kill -9? Will that have unwanted side effects? Why doesn't it die?

I am on Linux 2.6.24, Ubuntu flavoring.

share|improve this question
    
AHH. It was "stopped". I "kill -cont 3081", it comes back, but as soon as I touch a key, it gets "+Stopped" again. –  bobobobo Oct 5 '09 at 15:03
add comment

2 Answers 2

up vote 1 down vote accepted

kill -9 will stop the script. a simple kill command will wait for the script to gracefully stop, which will never happen in an infinite loop.

you should implement some exception catching mechanism to handle script failures. or even better - make a TSR service out of it instead of running in a simple loop

share|improve this answer
    
When you say "TSR" I think you mean "daemon". –  Dennis Williamson Oct 5 '09 at 16:18
    
old terms die hard :) –  dyasny Oct 5 '09 at 21:20
add comment

This question probably belongs on StackOverflow as it's more programming related than system admin. But does your program handle the SigInt signals?

http://stackoverflow.com/questions/1112343/how-do-i-capture-sigint-in-python

share|improve this answer
add comment

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.