COBOL Manual for TNS and TNS/R Programs

Process Initiation, Communication, and
Management
HP COBOL Manual for TNS and TNS/R Programs522555-006
31-30
Determining the Status
Search Mode
The PROCESS_GETINFOLIST_ routine lets you search for a process that meets one
or more of these criteria:
Has a specified process ID
Has a specified creator accessor ID
Has a specified process accessor ID
Has a specified home terminal
Has a priority not greater than a specified priority
Came from a specified loadfile name
For example, you can search for a process that is running at a priority of less than 40,
has $THIRTY as its home terminal, and was loaded from loadfile
$MEDIUM.PEPPER.STEAK.
Using search mode, you can implement processes for such tasks as determining
whether a certain named process is running, identifying processes that are running at
inappropriate priorities, or determining whether a process is using a certain terminal.
The only required parameter is the 2-byte binary item containing a processor and PIN
value. The routine uses this to determine where to start its search. The remaining
parameters can be present or specified as OMITTED. The values to be matched in the
search are specified by the same parameters the operating environment is to use to
return the values appropriate to the process it finds.
In Example 31-14, an HP COBOL program finds and reports all processes on its
system that have the same process accessor ID as the program.
DISPLAY "I am process (" CPU "," PIN "), named " PROCESS-NAME.
PERFORM CAPTURE-ACCESSOR-IDS.
DISPLAY "My creator accessor ID is " CREATOR-EDITED.
DISPLAY "My process accessor ID is " PROCESS-EDITED.
DISPLAY "My priority is " PRIORITY.
DISPLAY "My loadfile name is " PROGRAM-FILE-NAME.
DISPLAY "My home terminal is " HOME-TERMINAL.
STOP RUN.
CAPTURE-ACCESSOR-IDS.
MOVE CREATOR-ACCESSOR-ID TO BYTE-PAIR.
MOVE LEFT-BYTE OF CONSECUTIVE-BYTES TO NUMERIC-RIGHT-BYTE.
MOVE BYTE-AS-NUMBER TO CREATOR-GROUP.
MOVE RIGHT-BYTE OF CONSECUTIVE-BYTES TO NUMERIC-RIGHT-BYTE.
MOVE BYTE-AS-NUMBER TO CREATOR-MEMBER.
MOVE PROCESS-ACCESSOR-ID TO BYTE-PAIR.
MOVE LEFT-BYTE OF CONSECUTIVE-BYTES TO NUMERIC-RIGHT-BYTE.
MOVE BYTE-AS-NUMBER TO PROCESS-GROUP.
MOVE RIGHT-BYTE OF CONSECUTIVE-BYTES TO NUMERIC-RIGHT-BYTE.
MOVE BYTE-AS-NUMBER TO PROCESS-MEMBER.
Example 31-13. PROCESS_GETINFO_ Routine (page3of3)