Guardian Programmer's Guide

Table Of Contents
Creating and Managing Processes
Guardian Programmer’s Guide 421922-014
16 - 52
Suspending and Activating Processes
files and devices it has exclusive access to. However, if the error returned is 0, then
the process will not execute any more code.
The best way to ensure that the process is terminated and its resources freed is to wait
for system message -101 (Process deletion), which is sent to its creator when the
process terminates.
Suspending and Activating Processes
Remember that a process can alternate between the suspended and runnable states.
You can cause a process to change from one state to the other either by issuing
commands at the TACL prompt or programmatically by issuing system procedure calls.
You can suspend a runnable process by issuing the SUSPEND command at the TACL
prompt; you can suspend a process programmatically by calling the
PROCESS_SUSPEND_ procedure. To activate a suspended process, you can issue
the TACL RESUME command, or you can activate a process programmatically by
calling the PROCESS_ACTIVATE_ procedure.
This subsection describes the system procedure calls that suspend and activate
processes. For a description of how to use TACL commands to suspend and activate
processes, refer to the Guardian User’s Guide or the TACL Reference Manual
Suspending Your Own Process
To suspend your own process, you issue a PROCESS_SUSPEND_ procedure call
without specifying any process. By default, the operating system selects your process
for suspension:
CALL PROCESS_SUSPEND_;
The process then remains in the suspended state until reactivated by the RESUME
command or the PROCESS_ACTIVATE_ procedure call from another process.
Suspending Other Processes
To suspend a process other than your own, you supply the PROCESS_SUSPEND_
procedure with the process handle of the process you want to suspend. The process
handle is that returned by the PROCESS_LAUNCH_ procedure when the process was
created. If you do not know the process handle, you can use the
FILENAME_TO_PROCESSHANDLE_ procedure to find out the process handle; see
Converting Between Process Handles and Process File Names later in this section.
The following example suspends a process identified by process handle:
ERROR := PROCESS_SUSPEND_(PROCESS^HANDLE);
IF ERROR <> 0 THEN ...
The process then remains in the suspended state until reactivated by the RESUME
command or the PROCESS_ACTIVATE_ procedure.