Almost There - os.kill()
Robert Rawlins - Think Blue
robert.rawlins at thinkbluemedia.co.uk
Mon Sep 24 07:23:25 EDT 2007
Hello Guys,
Finally got around to sitting down to tidy up this script this morning but
I'm having a small syntax problem with os.kill() to kill a process on my
system. Here is the code:
def killApplication():
pid = file('/var/lock/MyApplication.lock').read().strip()
logging.info('Killing Application Process: %s' % pid)
os.kill(pid, 15)
logging.info('Application %s Killed' % pid)
As you can see if rips the PID from the lock file, which works fine as I get
log data which says 'Killing Application Process: 3079' exactly as I would
expect it too. However when I run this script I get the following error:
Traceback (most recent call last):
File "/pblue/new/Alive.py", line 50, in ?
main()
File "/pblue/new/Alive.py", line 47, in main
doCheck()
File "/pblue/new/Alive.py", line 43, in doCheck
killApplication()
File "/pblue/new/Alive.py", line 28, in killApplication
os.kill(pid, 15)
TypeError: an integer is required
Which would suggest its passing those arguments in as the wrong data types
to the kill command. What is the best way to convert these?
Thanks guys,
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070924/ab3bfe38/attachment.html>
More information about the Python-list
mailing list