0

I started VLC (with NDI plugin) in the command line using this Python code:

vlc = sp.Popen(["vlc", "-", "--aout", "NDI", "--vout", "NDI", url], shell=True)

(NDI is a video streaming network technology)

To stop the process i use:

sp.Popen(["taskkill", "/F", "/PID", vlc.pid, "/T"], shell=True)

I also have NDI network watcher (built into the Touchdesigner) which checks available NDI sources.

So here's the problem: when i use this Windows taskkill command to kill the VLC process, my watcher does not update the list of NDI sources. But if i just press the red cross in the opened VLC window, VLC closes and the list of sources is being updated properly.

So, what happens when i press this red cross? What is the difference between this action and taskkill'ing?

The thing i want to achieve is to be able to simulate this red cross behavior using command line to update my NDI source list.

2 Answers 2

0

There is almost no difference between the red X and taskkill.

There is a big difference between the red X and taskkill /f. Note the /f.

  • The "Close" button of a window sends the WM_SYSCOMMNAND(SC_CLOSE) message to a program's message loop, which by default generates a WM_CLOSE message to itself – asking it to close that particular window.

  • Regular taskkill just directly sends a WM_CLOSE message to a program's message loop, asking it to close all windows and exit.

  • "Forced" taskkill /f calls TerminateProcess(), which is similar to kill -9 on Linux – it is unconditional and the target process cannot intercept or delay it in any way.

0

So, what happens when i press this red cross?

This entirely depends on the application. Most traditional desktop applications, hitting the close button will trigger the closing event, this event is typically used to perform actions that are applicable when are closing the application (prompting to save a document, etc). What this event is called exactly entirely depends on the programming language the application is written in.

What is the difference between this action and taskkill'ing?

The process is immediately closed. If you "end task" on a process, the process is closed immediately, you can confirm this behavior by opening a Word document making a chance and Word will close without a save prompt. Likewise, if you close Word, it will prompt you to save the document. By forcefully ending the process taskkill /f you are skipping that event, the process ends immediately, so anything that typically would happen as VLC closes does not happen. My Word example would do the same thing with taskkill /f, end process was simply an easier experiment to conduct.

The thing i want to achieve is to be able to simulate this red cross behavior using command line to update my NDI source list.

I would stop forcefully closing the task.

1
  • Thank you for the answer. I tried to use taskkill without /f and it can't terminate the program, it keeps running. So, do you know what else can i do?
    – luddite478
    Commented Apr 9, 2020 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .