COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

* -- Get my process accessor id
ENTER TAL "PROCESS_GETINFO_"
USING PROCESS-HANDLE
OMITTED
OMITTED
OMITTED
OMITTED
OMITTED
OMITTED
OMITTED
MOMS-CAID
MY-PAID
OMITTED
OMITTED
OMITTED
OMITTED
OMITTED
OMITTED
GIVING ERROR-RETURN.
IF ERROR-RETURN NOT = 0
DISPLAY "Call to PROCESS_GETINFO_ returned an error code of "
ERROR-RETURN
STOP RUN.
* -- If my process accessor id matches MOM's creator accessor id, I can
* -- stop MOM before continuing
IF MY-PAID = MOMS-CAID
ENTER TAL "PROCESS_STOP_" USING MOMS-PROCESS-ID.
* ...
STOP RUN.
DISPLAY-PROCESS-NAME.
MOVE MOMS-PROCESS-NAME TO PNAME.
IF PNAME-FIRST-WORD-NUM < 0
MOVE MOMS-PROCESS-ID TO INTERNAL-NAME
DISPLAY "My creator is ("
NUMERIC-CPU "," NUMERIC-PIN ")-----"
MOMS-PROCESS-NAME
...
CAPTURE-CPU-PIN.
MOVE CPU-PART TO CPU-LOW-BYTE.
MOVE LOW-VALUES TO CPU-HIGH-BYTE.
MOVE PIN-PART TO PIN-LOW-BYTE.
MOVE LOW-VALUES TO PIN-HIGH-BYTE.
Monitoring Descendants’ Completion
The operating environment always sends messages about descendant processes to parent processes.
If your process starts another process, it might need to determine whether the process ran to normal
completion or terminated abnormally.
The HP COBOL run-time routines report the receipt of system messages only when the
RECEIVE-CONTROL paragraph specifies it. If you want a process that creates other processes to
be notified about termination or failure of these descendant processes:
Include a REPORT SYSTEM MESSAGES entry in the RECEIVE-CONTROL paragraph of the
parent process.
Have the parent process monitor $RECEIVE and watch for ABEND and STOP messages.
A process other than the actual creator can intercept the STOP and ABEND messages by using
the PROCESS_SETINFO_ routine to become the creator of record. See Changing the Creator ID.
Example 314 creates a FUP process and then watches for its termination.
Managing a Process 939