LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Killing external executable

Hello all,
I use LaunchExecutableEx / TerminateExecutable to synchronize with an
external executable. But when I kill it, its buffers are not flushed
properly. Is there a cleaner way to kill it from CVI ?

The documentation to TerminateExecutable has the following cryptic last
sentence:

Terminates an executable if it has not already terminated.
This function calls TerminateProcess to terminate the process. DLLs loaded
by the process being terminated are not given a chance to cleanup. Exit a
process using the ExitProcess function rather than terminating the process
using TerminateProcess.

I assume that both ExitProcess and TerminateProcess are Windows functions.
Bonus points for a way to do this with the Linux version of CVI...
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 1 of 5
(4,997 Views)

Don't know about Linux, but all the NI function is doing is calling the Win32 SDK TerminateProcess function.

 

It is considered drastic to do this in the sense that, as you noted, DLL's aren't notified of the process/thread detach,  handles are left open, file buffers not flushed, etc.  

 

The Win32 philosophy is that the process should be signaled to terminate, and then terminates itself, since only the process directly "knows" what resources it has open.   So you're stuck with polling of some kind or another, whereby the application has to periodically check and see if it's been told to terminate itself.

 

It may be that TerminateProcess results in a terminate message being sent to the main window message queue.   The top level window in a CVI app is also a true window, and there's a message queue you can get to, in a roundabout way, as I recall.

 

As a general rule, I think the OS is able to pretty much clean up after a TerminateProcess call, though it's certainly not "clean".  I think TerminateProcess is about the same as using the task manager to kill an application.

 

Menchar

 

 

0 Kudos
Message 2 of 5
(4,989 Views)

Hello Guillaume,

 

I haven't been able to find a specific CVI function that will accomplish this for you in Linux, however, I believe you should be able to code your program to issue commands to the Linux Operating system. See the following links on how to terminate a process/executable in linux. Rather than calling a single function, you may need to write a few lines of code to issue the proper commands.

 

How Do I Stop a Running Program in Linux

 

Kill Process in Linux 

 

Both of these links provide the same method of terminating the process/executable. I thought the first link was a little more informative and easier to read.

 

Hope this helps Guillaume! 

Manooch H.
National Instruments
0 Kudos
Message 3 of 5
(4,929 Views)

hello Guillaume Dargaud

 

I am a student.There are some questions to ask you .I'll be appriciate to receive your apply.

 

I am using labwindows/CVI developping a instrument in embedded linux environment.   I want to get the rpm package of  labwindows/CVI run-time module to install it on linux OS,but I haven't find one in the web ,please tell me how can I get it ?

 

By the way ,can I get some example program from you ,if not ,can you tell me where there are.

 

I am waiting for your replly, Thank you  very very much!!!

From:Yutian jin.

Beijing China

 

0 Kudos
Message 4 of 5
(4,853 Views)
Hello Yutian,
well, I don't know how to _normally_ get the copy of either the runtime of
the cvicc for Linux (those two are separate). They are not part of even the
full LV/LW packages (although they absolutely should be).
I had to ask NI for my copies and received them as a courtesy since we do a
lot of things in common with them (organize workshops and formations in our
buildings). We have already shifted all our development from Windows to
Linux, so that's rather crucial software.
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 5 of 5
(4,701 Views)