Guardian Programmer's Guide

Table Of Contents
Creating and Managing Processes
Guardian Programmer’s Guide 421922-014
16 - 63
Converting Between Process Handles and
Process File Names
and unnamed process file names. For a named process, the operating system looks
up the process handle in the DCT, and it returns error 14 (device does not exist) if the
process name does not exist.
For unnamed processes, the operating system does not check for the existence of the
process. It creates a process handle from the information provided in the process file
name.
To use the FILENAME_TO_PROCESSHANDLE_ procedure, you must supply the
procedure with the process file name and a return variable for the process handle. The
following example converts a named process file name into a process handle:
PROCESS^NAME ':=' "$SRV1" -> @S^PTR;
NAME^LENGTH := @S^PTR '-' @PROCESS^NAME;
ERROR := FILENAME_TO_PROCESSHANDLE_(PROCESS^NAME:NAME^LENGTH,
PROCESS^HANDLE);
IF ERROR = 14 THEN
BEGIN
SBUFFER ':=' "No Such Process " -> @S^PTR;
WCOUNT := @S^PTR '-' @SBUFFER;
CALL WRITEX(TERM^NUM,SBUFFER,WCOUNT);
END;
Converting a Process Handle Into a Process File Name
To convert a process handle into a process file name, use the
PROCESSHANDLE_TO_FILENAME_ procedure.
When using the PROCESSHANDLE_TO_FILENAME_ procedure, you must supply the
process handle. The procedure returns the process file name in the name parameter
and the name length in the namelen parameter.
If the process handle refers to a named process, then the procedure looks up the
process file name in the DCT. (For a process pair, the procedure returns the current
primary process.) If the process handle refers to an unnamed process, then the
procedure returns the unnamed process file name using information contained in the
process handle itself.
The PROCESSHANDLE_TO_FILENAME_ procedure returns the fully qualified
process name (including the node name). The sequence number is optional. By
setting bit 15 of the options parameter, you suppress the sequence number.
The following example converts a process handle into a fully qualified process file
name, without the sequence number:
LITERAL MAXLEN = ZSYS^VAL^LEN^FILENAME,
NO^SEQNO = 1,
SEQNO = 0;
.
.
OPTIONS := NO^SEQNO;
CALL PROCESSHANDLE_TO_FILENAME_(PROCESS^HANDLE,
NAME:MAXLEN,