"phil" <[EMAIL PROTECTED]> wrote:
from win32all EnumProcesses gives me the pids, then OpenProcess(pid) gives me a handle. Then what? GetModuleFileNameEX? It requires two handles as args and I can't figure out which one is the handle from OpenProcess and what it wants for the other one and I can't find any Win32 SDK docs that help.
http://msdn.microsoft.com/library/en-us/perfmon/base/getmodulefilenameex.asp
describes a function with two [in] arguments, and one [out] argument. the first argument is the process handle, the second a module handle; the second argument can be NULL.
This ought to be a nobrainer. But Nooo. Its Windows.
it can be pretty tricky on other platforms too; that's why Unix programs usually solve this by writing their PID to a file in a known location, so that other programs can find them without having to resort to more or less stupid tricks.
</F>
On Linux, you can just scan the /proc directory. This is what the procps package does. From the command line:
310 $ ps -o cmd --no-heading 867 metalog [MASTER]
In the pyNMS package on sourceforge (http://sourceforge.net/projects/pynms) there is a module called Linux.procfs, and in it there is an object called "ProcStat" that lets you get the process info easily (if running on Linux).
Python> import procfs
Python> procfs.ProcStat(1)
Python> pid1 = procfs.ProcStat(1)
Python> print pid1
cmdline: init [3]
cmaj_flt: 63690958
cmin_flt: 186761321
cnswap: 0
command: (init)
eip: 35
esp: 43
exit_signal: 0
flags: 256
it_real_value: 0
maj_flt: 224
min_flt: 1963
mm_end_code: 134538444
mm_start_code: 134512640
mm_start_stack: 3221225232
nice: 0
nswap: 0
pgrp: 0
pid: 1
ppid: 0
priority: 15
processor: 0
rlim_cur: 4294967295
rss: 117
session: 0
sig_blocked: 0
sig_catch: 671819267
sig_ignore: 1475401980
sig_pending: 0
start_time: 42
state: S
tms_cstime: 731277
tms_cutime: 9593767
tms_stime: 237
tms_utime: 75
tty_nr: 0
tty_pgrp: -1
vsize: 1429504
wchan: 3222957162
-- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 ===================================================================== -- http://mail.python.org/mailman/listinfo/python-list
