Almost There - os.kill()

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



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




From: at
[ at]
On Behalf Of Robert Rawlins - Think Blue
Sent: 24 September 2007 12:23
To: python-list at
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()

      'Killing Application Process: %s' % pid)


       os.kill(pid, 15)

'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/", line 50, in ?


  File "/pblue/new/", line 47, in main


  File "/pblue/new/", line 43, in doCheck


  File "/pblue/new/", 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,



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list