comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: getpid in Mac OS X
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: getpid in Mac OS X [message #39765] Mon, 14 June 2004 12:43 Go to previous message
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
Miguel Angel Cordoba wrote:
> Thank you,
> but this solution only works if only one IDL process is running. In my
> case there are 4 processes and I need all the PID's.

OK, so all that takes is a few strokes of the pen...
The function below returns a list. Below the code snippet is an
example run.
Note that this is Darwin (OS X) specific. It wouldn't take much to
make it work on Linux.

---------code---------
function idl_pids
pid = -1 ;--- default value appropriate for Mac, PC

if (!version.os EQ 'darwin') then begin
spawn, 'ps', list
print, '----------'
print, list
print, '----------'
w = where((strpos(list, 'Applications') GT 0) $
and (strpos(list, 'idl') GT 0), count)
if (count LT 1) then begin
print, 'idl_pids error: no valid jobs'
return, -1
endif
pid = lonarr(count)
for i=0,count-1 do $
pid(i) = long( (strsplit(list(w(i)), ' ', /EXTRACT))(0) )
endif

return, pid
end
------ end of code ------

IDL> print, idl_pids()
----------
PID TT STAT TIME COMMAND 11879 std Ss 0:00.06 -csh
11898 std S+ 0:03.54 /Applications/idl_6.0/bin/bin.darwin.ppc/idl
11947 std S+ 0:00.02 tcsh -c ps 11885 p2 Ss 0:00.06 -csh
11901 p2 S+ 0:03.36 /Applications/idl_6.0/bin/bin.darwin.ppc/idl
11891 p3 Ss 0:00.07 -csh
11894 p3 S+ 0:03.75 /Applications/idl_6.0/bin/bin.darwin.ppc/idl
----------
11898 11901 11894

Get rid of the print statements if you like.
M. Katz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: dates transformation
Next Topic: Re: dates transformation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 03:10:08 PDT 2025

Total time taken to generate the page: 0.79962 seconds