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 #39900 is a reply to message #39765] Tue, 15 June 2004 02:22 Go to previous message
Miguel Angel Cordoba is currently offline  Miguel Angel Cordoba
Messages: 13
Registered: April 2004
Junior Member
Thank you,
but the problem is that I need the PID off the process. If I execute three
processes all off them needs his PID and with 'ps' list I think that
it's not possible.
With the 'ps' method I can find the three PID's but I can't know who is his
owner.
With the "call_external" method in all the programs I execute this to
get the
PID off the process.

SOLARIS:
my_pid=CALL_EXTERNAL('/lib/sparcv9/libc.so','getpid')

LINUX
my_pdi=CALL_EXTERNAL('/lib/i686/libc.so.6','getpid')

then the problem in Mac Os X is the error:

IDL>pid=CALL_EXTERNAL('/usr/lib/libc.dylib','getpid')
% CALL_EXTERNAL: Error loading sharable exectuble.
Symbol: getpid, FILE=/usr/lib/libc.dylib
not a Mach-O MH-BUNDLE file type

Any ideas?. Thank you.

M. Katz wrote:

> 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
>
>

--
_________________________________________________________
Miguel Angel Cordoba
---------------------------------------------------------
Grup de Recerca Aplicada en Hidrometeorologia (GRAHI-UPC)
http://www.grahi.upc.es
---------------------------------------------------------
Centre membre de la Xarxa d'Innovacio Tecnologica XIT
http://www.cidem.com/xarxait
_________________________________________________________
[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: Sun Oct 12 11:20:13 PDT 2025

Total time taken to generate the page: 2.23756 seconds