Utility Library Chapter 8
LabWindows/CVI Standard Libraries 8-82 © National Instruments Corporation
TerminateExecutableint status = TerminateExecutable (int executableHandle);
Purpose
Attempts to terminate an executable if it has not already terminated.
Under Windows the system terminates an executable by sending close messages to each window
in the application. If the application does not honor the close messages, then the application does
not terminate. The TerminateExecutable function gives up control for a limited period to
give the application an opportunity to process the close messages. This period should be
sufficient for all applications. When you need to allow more time, your program can call the
ProcessSystemEvents function in a loop, as shown in the following example.
Example
#define TIME_LIMIT 5.0 /* number of seconds */
double startTime;
startTime = Timer ();
TerminateExecutable (handle);
while (!ExecutableHasTerminated(handle)
&& (Timer()-startTime > TIME_LIMIT))
ProcessSystemEvents();
Under UNIX, you can allow more time by sending the SIGKILL message to the process. The
SIGKILL message cannot be blocked, caught, or ignored, and therefore should always succeed.
Parameters
Input executableHandle integer The executable handle acquired from
LaunchExecutableEx.
Return Value
status integer Result of operation.
Return Codes
-1 Handle is invalid.
0 Handle is invalid.