Message9145
Title pretty much explains the problem. After studying this a bit, I was able to implement getting pid so that it works at least on Windows 7 and Linux Mint. The resulting code is at the end of this description and it can be tested by running the attached script that contains also simple code to verify the results.
If there's interest, I can take a look at turning this into a pull request. Final solution ought to have error handling at least when accessing private fields. I would assume it's better to return None than raise an exception on error.
----------8<------------------8<----------------------
import os
if os.sep == '/':
def get_pid(process):
field = process.getClass().getDeclaredField('pid')
field.setAccessible(True)
return field.getLong(process)
else:
import ctypes
GetProcessId = ctypes.cdll.kernel32.GetProcessId
GetProcessId.argtypes = (ctypes.c_long,)
def get_pid(proces):
field = process.getClass().getDeclaredField('handle')
field.setAccessible(True)
handle = field.getLong(process)
return GetProcessId(handle) |
|
Date |
User |
Action |
Args |
2014-10-14 10:44:27 | pekka.klarck | set | recipients:
+ pekka.klarck |
2014-10-14 10:44:27 | pekka.klarck | set | messageid: <1413283467.17.0.0214186478653.issue2221@psf.upfronthosting.co.za> |
2014-10-14 10:44:27 | pekka.klarck | link | issue2221 messages |
2014-10-14 10:44:26 | pekka.klarck | create | |
|