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-33
Identifying the Creator
Identifying the Creator
A process can use the PROCESS_GETINFO_ routine to determine the identity of the
process that created it, which enables the process to be selective. It can terminate if it
was created by an inappropriate agent. It can open different files depending on the
identity of its creator. It can send messages to its creator explicitly. It can even suspend
or stop its creator if its process accessor ID matches its creator’s creator accessor ID.
When you issue a RUN command, such as RUN X, your TACL process initiates the
specified process. The process produced from loadfile X has the TACL process as its
creator.
In addition, suppose your process uses CREATEPROCESS or
CLU_PROCESS_CREATE_ to initiate a new process. The child process can discover
the identity of its parent process, if the child is not running as a process pair (in that
case, the parent of the primary process is the backup process).
Example 31-15 uses the PROCESS_GETINFO_ routine to report the identity of its
creator to its home terminal. To handle the possibility of an unnamed process, the
example uses the same mechanism to decipher its creator’s process name that is used
in WHO-SENT-THAT in Identifying the Message Source. After identifying its creator
process, the example determines whether it can stop its creator; if it can, it does.
REPORT-A-MATCH.
PERFORM EDIT-CPU-PIN.
DISPLAY "(" NUMERIC-CPU "," NUMERIC-PIN ") "
PROCESS-EDITED " "
PRIORITY " ".
DISPLAY PROGRAM-FILE-NAME " "
HOME-TERMINAL " ".
EDIT-CPU-PIN.
MOVE CPU-PIN TO BYTE-PAIR.
PERFORM SEPARATE-BYTE-PAIR.
MOVE NUMERIC-LEFT-BYTE TO NUMERIC-CPU.
MOVE NUMERIC-RIGHT-BYTE TO NUMERIC-PIN.
EDIT-ACCESSOR-ID.
MOVE PROCESS-ACCESSOR-ID TO BYTE-PAIR.
PERFORM SEPARATE-BYTE-PAIR.
MOVE NUMERIC-LEFT-BYTE TO PROCESS-GROUP.
MOVE NUMERIC-RIGHT-BYTE TO PROCESS-MEMBER.
SEPARATE-BYTE-PAIR.
MOVE LOW-VALUES TO SEPARATED-BYTES.
MOVE LEFT-BYTE OF CONSECUTIVE-BYTES TO LEFT-LOW-BYTE OF SEPARATED-
BYTES.
MOVE RIGHT-BYTE OF CONSECUTIVE-BYTES TO RIGHT-LOW-BYTE OF SEPARATED-
BYTES.
INCREMENT-CPU-OR-QUIT.
IF CURRENT-CPU < 15
ADD 1 TO CURRENT-CPU
MOVE CURRENT-CPU TO BINARY-WORKTABLE
MULTIPLY 256 BY BINARY-WORKTABLE
MOVE BINARY-WORKTABLE TO CPU-PIN
ELSE
DISPLAY "------------------------------"
STOP RUN.
Example 31-14. Reporting Processes With Program’s Accessor ID (page 3 of 3)