Almost There - os.kill()

Robert Rawlins - Think Blue robert.rawlins at thinkbluemedia.co.uk
Mon Sep 24 13:40:07 CEST 2007


Woops,

 

Spoke too soon, just wrapped them in int() and it works a charm :-D

 

Rob

 

From: python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org
[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org]
On Behalf Of Robert Rawlins - Think Blue
Sent: 24 September 2007 12:23
To: python-list at python.org
Subject: Almost There - os.kill()

 

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/a3cca314/attachment.html>


More information about the Python-list mailing list