[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: idl process id





> > IDL> result=call_external('/lib/libc.so.1.9','getpid')

> Does anyone know how to get this to work on a DEC alpha?
> I can't find a shared object version of libc in my /lib
> directory.

Look in /shlib instead:

IDL> result=call_external('/shlib/libc.so','getpid')
IDL> print,result 
       31185 

With the easy-going way of adding new system routines that I found 
two days ago, just compile the below included C-code into a 
shareable object file (remember to link in $IDL_DIR/bin/bin.alpha),
initialize with

IDL> print,call_external('gmain.so','addmain')

and then you go:

IDL> print,getpid()

(This is perhaps not a good example of this utility - since it's
possible to do this with a single-line call_external statement,
but it does illustrate how easy it is to expand IDL by adding
"built-in" routines that are able to return honest-to-RSI *variables*).

Regards,

Stein Vidar

-----------------------------------------------------gmain.c

#include <unistd.h>
#include <stdio.h>
#include "export.h"

#define NULL_VPTR ((IDL_VPTR) NULL)

IDL_VPTR GETPID(int argc, IDL_VPTR argv[])
{
  IDL_VPTR tmp = IDL_Gettmp();

  if (tmp==NULL_VPTR) {
    IDL_Message(IDL_M_NAMED_GENERIC,IDL_MSG_LONGJMP,
		"Couldn't create temporary variable");
  }
  
  tmp->type = IDL_TYP_LONG;
  tmp->value.l = getpid();

  return tmp;
}

IDL_SYSFUN_DEF main_def[] = {{(IDL_FUN_RET) GETPID,"GETPID",  0, 0}};

IDL_LONG addmain(int argc,char *argv[])
{
  IDL_AddSystemRoutine(main_def,IDL_TRUE,1); /* Just add getpid */
  return 0;
}