              <<< VAXAXP::NOTES$:[NOTES$LIBRARY]VMSNOTES.NOTE;1 >>>
               -< VAX and Alpha VMS - Digital Internal Use Only >-
================================================================================
Note 1311.8             Logical name table number and PID                8 of 10
COMEUP::SIMMONDS "Every Action Fits A Belief."       68 lines   6-AUG-1996 03:38
                                   -< prog >-
--------------------------------------------------------------------------------
.0>    pid number? I mean with a lexical or a system service or rtl routine or
.0>    program. Thanks
       ^^^^^^^
    Sample program for OpenVMS Alpha.. tested using DEC C V5.3 on OpenVMS
    Alpha V6.2  [NB: Do Not give this to any Customer!]


#if 0
$ CC PROG + SYS$LIBRARY:SYS$LIB_C/LIBRARY
$ LINK/SYSEXE PROG
$ SET PROCESS/PRIVI=CMKRNL
$ MCR []PROG "Hexadecimal_PID"
#endif
#include <stdlib.h>
#include <stdio.h>

#include <exe_routines.h>
#include <ssdef.h>
#include <starlet.h>

extern PCB * exe_std$cvt_epid_to_pcb(int epid);
int get_JIB_address(int epid, JIB ** jibp);

int
main(int argc, char *argv[])
{
int
    cv,
    external_pid;
static struct KMODE_ARGLST {
    int
        argc;
    unsigned long
        epid;
    JIB
        ** jib_h;
    } get_JIB_arglist;
static JIB
    * target_jib;

external_pid=strtoul(argv[1],0,16);

get_JIB_arglist.argc=2;
get_JIB_arglist.epid=external_pid;
get_JIB_arglist.jib_h=&target_jib;
cv=sys$cmkrnl(get_JIB_address,&get_JIB_arglist);

if(target_jib)
    (void)printf("Job table for PID %08.8X is: LNM$JOB_%08.8X\n",
			external_pid,target_jib);
else
    (void)printf("%%Invalid PID!\n");

return SS$_NORMAL;
}


int
get_JIB_address(int epid, JIB ** jib_h)
  {
  PCB
    * pcb;

  pcb=exe_std$cvt_epid_to_pcb(epid);
  *jib_h=(pcb)?pcb->pcb$l_jib:(JIB *)pcb;

  return SS$_NORMAL;
  }
