Atle Borsholm showed me this technique for getting IDL’s process identifier (or process id or pid) on Linux (though it should work on any UNIX-based system):
IDL> pid = call_external('libc.so.6', 'getpid') IDL> print, pid 22468
I used this recently with pmap to get the memory map of an IDL process; I was curious to see how the OS reported the memory use of IDL plus the shared libraries it uses. For example, SPAWN a call to pmap:
IDL> spawn, 'pmap' + string(pid), pid_memory IDL> print, ulong((strsplit(pid_memory[-1], /extract))[-1]) 137672
where pmap returns the total memory use in kilobytes, and compare this with the output from MEMORY, scaled to KB:
IDL> print, memory(/current) / 1024 1029
The difference is that MEMORY (as noted on its Help page) doesn’t include memory used by shared libraries.
This worked for me on Mac OS X:
IDL> print, call_external('libc.dylib', 'getpid') 44495I also have a MG_PID routine in mglib that returns the PID using the IDL API which is more cross-platform.
Oh, should’ve looked harder — not only do you have MG_PID, but Ray Sterner also has GET_IDLPID.
Jim Pendleton also has a technique for Windows:
IDL> ProcessID = StrTrim(Call_External('kernel32.dll', 'GetCurrentProcessId'), 2)