Article 147457 of comp.os.vms:
I think the following code will do what you want.  Just change it to a 
routine.  Hope this helps.

Arlen Williams
The SABRE Group
arlen_williams@amrcorp.com

#include <jpidef.h>
#include <pscandef.h>
#include <ssdef.h>
#include <starlet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

main( int argc, char *argv[] )
  {
    unsigned long status;
    long          pid = -1;
    char          node_name[ 4 ] = "*";
    char          proc_name[ 16 ];
    static char   jps_nodename[ 17 ];
    static long   jps_nodenamelen;
    static char   jps_prcnam[ 24 ];
    static long   jps_prcnamlen;
    struct _JPIELEM_
      {
        short jpe_buflen;
        short jpe_item;
        char *jpe_bufadr;
        long *jpe_retlen;
      };
    struct _JPIELEM_ jpibuff[] =
      {
        {17, JPI$_NODENAME, jps_nodename, &jps_nodenamelen },
        {24, JPI$_PRCNAM,   jps_prcnam,   &jps_prcnamlen   },
        {0,  0,             NULL,          NULL            }
      };
    struct
      {
        unsigned short  psc_len;
        unsigned short  psc_code;
        void           *psc_addr;
        unsigned long   psc_itmf;
      }node[ 4 ];
    struct
      {
        unsigned short status;
        unsigned short count;
        unsigned long  info;
      }iosb;

    strcpy( proc_name, argv[ 1 ] );

    node[ 0 ].psc_len  = strlen( node_name );
    node[ 0 ].psc_code = PSCAN$_NODENAME;
    node[ 0 ].psc_addr = node_name;
    node[ 0 ].psc_itmf = PSCAN$M_WILDCARD;
    node[ 1 ].psc_len  = strlen( proc_name );
    node[ 1 ].psc_code = PSCAN$_PRCNAM;
    node[ 1 ].psc_addr = proc_name;
    node[ 1 ].psc_itmf = PSCAN$M_EQL;
    node[ 2 ].psc_len  = 0;
    node[ 2 ].psc_code = 0;
    node[ 2 ].psc_addr = 0;
    node[ 2 ].psc_itmf = 0;

    status = sys$process_scan( &pid, node );
    if ( !( status & SS$_NORMAL ) )
      {
        printf( "Call to sys$process_scan failed - %d\n", status );
      }
    else
      {
        status = sys$getjpiw( 0, &pid, NULL, &jpibuff, &iosb, NULL, NULL );
        if ( ( status == SS$_NOMOREPROC ) ||
             ( iosb.status == SS$_NOMOREPROC ) )
          {
            printf( "Process not found!" );
          }
        else if ( ( status == SS$_SUSPENDED ) || ( status == SS$_NORMAL ) )
          {
            jps_nodename[ jps_nodenamelen ] = '\0';
            printf( "Process found on %s!", jps_nodename );
          }
        else
          {
            printf( "Call to sys$getjpiw failed %d %d", status, iosb.status );
          }
      }
    exit( 0 );
  

Received: from sabre.net (ontime.sabre.net [199.100.49.3]) by amrcorp.com (8.7.1/8.7.1) with SMTP id RAA01820 for <Arlen_Williams@AMRCORP.COM>; Tue, 14 May 1996 17:16:29 -0500 (CDT)
Received: (from uucp@localhost) by sabre.net (8.6.11/8.6.11) id RAA08097 for <Arlen_Williams@AMRCORP.COM>; Tue, 14 May 1996 17:16:28 -0500
Received: from mvb.saic.com(204.115.176.10) by sabre.net via smap (V1.3)
	id sma007918; Tue May 14 17:14:37 1996
From: ghshouse@aldebaran.oac.uci.edu (George Shouse)
X-Newsgroups: comp.os.vms
Subject: Obtaining names of SCS nodes in a cluster.
Date: 14 May 1996 21:49:57 GMT
Organization: University of California, Irvine
Lines: 17
Message-ID: <4nav65$9k6@news.service.uci.edu>
To: Info-VAX@Mvb.Saic.Com
X-Gateway-Source-Info: USENET

I have RTFM'd for a while and cannot find a good way to do this.
It may be that I have to spawn a subrocess and do a SHOW CLUSTER
and parse that output, but I'm hoping for a better way.

Here is the scenario:

I have a program which should only have one instance running cluster-wide.
I currently use a list of member nodes and cycle through them using
$GETJPI to see if this process is running on any other member.  I'd
like to generalize the code so that it discovers the cluster members
and checks for this process.

Any help is much appreciated.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
George Shouse                                     ghshouse@oac.uci.edu 
University of California at Irvine    Information and Computer Science



