LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to run shell code that you can kill asynchronously?

Solved!
Go to solution

Let's say I have a bit of shell code I'm running with System Exec.vi that takes a while to complete (several seconds to a minute). My program needs the output of this shell code, so we can't simply run it entirely in the background (unless I'm missing some way to asynchronously collect the stdout). In an event driven program, if the user wants to close the program, this shell code should be stopped, but currently it cannot be stopped while also collecting the output from stdout.

 

Thoughts?

0 Kudos
Message 1 of 4
(1,436 Views)

And yes, I'm aware of taskkill, but that seems like a blunt hammer in comparison to a proper PID/signal oriented approach, especially in the cases that you accidentally axe some other process that happens to be running under the same shell.

0 Kudos
Message 2 of 4
(1,431 Views)

Ideally it would work like the `subprocess.Popen` style of external async calls like you have in Python

0 Kudos
Message 3 of 4
(1,429 Views)
Solution
Accepted by topic author ijustlovemath

@ijustlovemath wrote:

My program needs the output of this shell code, so we can't simply run it entirely in the background (unless I'm missing some way to asynchronously collect the stdout).


There is a .NET way of getting stdout.  I found it on the forums once and used it, but I could not find it again when I looked recently.  But it does exist.

 

Edit: might have been this one here: https://forums.ni.com/t5/LabVIEW/Real-time-Command-Line-Interface-System-Exec/m-p/3183320/highlight/...

0 Kudos
Message 4 of 4
(1,401 Views)