COBOL Manual for TNS and TNS/R Programs

Process Initiation, Communication, and
Management
HP COBOL Manual for TNS and TNS/R Programs—522555-006
31-36
Monitoring Descendants’ Completion
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 31-16 creates a FUP process and then watches for its termination.
Example 31-16. Monitoring Completion of Descendant Processes (page1of3)
?ENV COMMON
?SAVE ALL
?SEARCH $SYSTEM.SYSTEM.COBOLLIB
IDENTIFICATION DIVISION.
PROGRAM-ID. FUPPERWARE.
AUTHOR. TERRY COBOL.
INSTALLATION. TRANSACTIONS ANONYMOUS.
DATE-WRITTEN. 29 FEBRUARY 1988.
DATE-COMPILED.
*************************************************************************
* This program creates a FUP process and watches for its termination. *
*************************************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. HP TXP.
OBJECT-COMPUTER. HP TXP.
SPECIAL-NAMES.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MESSAGE-IN-FILE
ASSIGN TO "$RECEIVE"
FILE STATUS IS RECEIVE-FILE-STATUS.
I-O-CONTROL.
RECEIVE-CONTROL.
TABLE OCCURS 1 TIMES
SYNCDEPTH LIMIT IS 1
MESSAGE SOURCE IS MESSAGE-SOURCE-REC
REPORT SYSTEM MESSAGES.
DATA DIVISION.
FILE SECTION.
FD MESSAGE-IN-FILE
LABEL RECORDS ARE OMITTED.
01 MESSAGE-IN.
05 SYS-MSG-CODE PIC S9(4) COMP.
88 SYS-MSG-STOP VALUE -101.
05 SYS-MSG-PROCNAME PIC X(6).
05 FILLER PIC X(66).
05 SYS-MSG-STOP-FLAG NATIVE-2.
05 FILLER PIC X(948).