This function sends a signal to an external program.
This can both be used to stop a running program, and to communicate with the program.
When the program is stopped, extProgramStatus must be called to release the handle.
Input:
handle : SYSHANDLE
A handle to the program to send the signal to.
signal : DINT (default 15)
The signal to send. Common values are:
9
|
- Kill signal. Kills the program immediately.
|
10
|
- User signal 1
|
12
|
- User signal 2
|
15
|
- Terminate signal. Requests that the program terminates.
|
18
|
- Continue signal. Requests that a stopped program continues.
|
19
|
- Stop signal. Requests the program to stop.
|
Returns: INT
0
|
- The signal was sent to the program.
|
-1
|
- Invalid handle.
|
-2
|
- Invalid signal.
|
-3
|
- Could not find program
|
-4
|
- Permission failed.
|
-5
|
- Failed to send signal
|
Declaration:
FUNCTION extProgramSignal : INT;
VAR_INPUT
handle : SYSHANDLE;
signal : DINT;
END_VAR;
Example:
INCLUDE rtcu.inc
PROGRAM test;
VAR
rc : INT;
signal : DINT;
handle : SYSHANDLE;
END_VAR;
BEGIN
...
fsMediaOpen(media := 1);
rc := extProgramStart(handle := handle, path := "B:\SYSTEM\EXT\SERVER.RPX",
args := "-port 3490 -name $"test server$"");
DebugFmt(message := "Server started: \1", v1 := rc);
...
rc := extProgramSignal(handle := handle, signal := 9);
DebugFmt(message := "Send kill: \1", v1 := rc);
rc := extProgramStatus(handle := handle, code := signal);
IF rc = 2 THEN
DebugFmt(message := "Program was terminated with the \4 signal", v4 := signal);
END_IF;
END;
END_PROGRAM;
|