I am trying to use python to close VLC while it is recording audio. Currently I am using:
os.kill(pid,pid)
This works but is closing VLC abruptly and not allowing the recording file to close properly, thus corrupting it. If I manually close the VLC GUI instance than the recording file will not be corrupted.
So basically I am looking for a python command to close an application that emulates the 'Close' button on the application's GUI.
Or, perhaps there is another way. Such as closing the .wav file where the recording is being written, before killing the VLC process? I also put some work into this, but didn't get any results.
Thanks for the help!
You're using the function wrong, you'll likely want something like this:
from signal import SIGTERM
os.kill(pid,SIGTERM)
The second parameter specifies the interrupt. Also often used is SIGKILL which is a hard kill, likely same as you had before. You can find more about the linux signals here. In windows your options are more limited, see the python docs for available signals.
By providing pid also for the second parameter you probably set a quite heavy kill signal, that terminated the application immediately, without closing files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With