COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Managing a Process
Besides creating processes and communicating with processes, a process might need to obtain
information about itself or about some other process in the same system or another system on the
same Expand network.
Determining the Process Handle
If a process has a record of its process handle—process name, processor number, and number of
the process within that processor (also called process identification number or PIN)—it can:
• Generate more useful diagnostic messages by including the process handle information and
the time and date
• Use its knowledge of its location (processor number) in creating other processes with which
it must communicate
• Obtain information from the operating system routines that require the processor number and
PIN as parameters
A process can obtain its process ID by passing its process number to the
PROCESSHANDLE_DECOMPOSE_ procedure, which returns the processor and PIN values as
separate integer values. If you do not know the process number, you can get it by calling the
PROCESSHANDLE_GETMINE_ procedure.
Example 308 PROCESSHANDLE_GETMINE_ and PROCESSHANDLE_DECOMPOSE_ Procedures
WORKING-STORAGE SECTION.
01 PROCESS-HANDLE PIC X(20).
01 CPU-PIN.
05 CPU PIC S9(2) COMPUTATIONAL.
05 PIN NATIVE-2.
01 ERROR-NUMBER PIC S9(5) COMPUTATIONAL.
01 NULL-PH PIC X(20) VALUE ALL HIGH-VALUES....
PROCEDURE DIVISION....
ENTER TAL "PROCESSHANDLE_GETMINE_"
USING PROCESS-HANDLE
GIVING ERROR-NUMBER
ENTER TAL "PROCESSHANDLE_DECOMPOSE_"
USING PROCESS-HANDLE
CPU
PIN
GIVING ERROR-NUMBER
Determining the Node (System Number)
When NonStop systems are linked together through Expand to constitute a network, each system
(or node) of the network has a system number. If copies of a process are running on different
nodes, the process might need to determine the system number of the system on which it is running.
The process might report diagnostic messages to a central log and include its system name, number,
or both.
A process can obtain the system number of the system on which it is running by calling the routines
PROCESSHANDLE_GETMINE_, PROCESSHANDLE_DECOMPOSE_, and
NODENUMBER_TO_NODENAME_, as Example 309 shows.
Example 309 Determining a Process’s Node (System Number)
IDENTIFICATION DIVISION.
PROGRAM-ID. WHERE-AM-I.
AUTHOR. BECK COBOL.
INSTALLATION. TRANSACTIONS ANONYMOUS.
DATE-WRITTEN. 29 FEBRUARY 1988.
DATE-COMPILED.
Managing a Process 929










