Close one after one with the exec node the 2 instances of vlc displayed

I launch vlc from nodered ; the exec node give the pid 1585

So, in a terminal :
pi@raspberrypi:~ $ kill 1585

Answer : bash: kill: (1585) - Aucun processus de ce type

If you have separate exec nodes then you shouldn't need to worry about the pid. Send the kill to the one that started it and it should do it.

What command are you using to start vlc?

That is strange but like @Colin and @dceejay suggested, it'll likely be easier to send the kill signal directly to the exec nodes.

Yes you are all right but I tried this approach because I don't know how to set up the kill sequence.
(I launch vlc with: "DISPLAY =: 0 cvlc")

Could you share your flow where you start the processes so it'd be easier to help with that?

In case you've missed:

This process works on the first kill and not the second

[{"id":"a8f82002.3b703","type":"exec","z":"b15d43aa.8177d","command":"DISPLAY=:0 cvlc http://listen.radioking.com/radio/132073/stream/171985","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"VLC Radio","x":530,"y":3820,"wires":[[],[],[]]},{"id":"8617a53e.732ae8","type":"inject","z":"b15d43aa.8177d","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":3820,"wires":[["a8f82002.3b703"]]},{"id":"300f27d9.a4ff58","type":"inject","z":"b15d43aa.8177d","name":"","topic":"","payload":"SIGTERM","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":3960,"wires":[["2cd1f86c.c7f418"]]},{"id":"2cd1f86c.c7f418","type":"change","z":"b15d43aa.8177d","name":"","rules":[{"t":"set","p":"kill","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":3960,"wires":[["a8f82002.3b703"]]}]

I only see one exec node. What the others were suggesting was to create two exec nodes, one for each. This way you can target the kill msg to the one you want close.

If you start two processes by pressing inject twice, I would guess only the one started last will be killed by sending the SIGTERM message.

If you click the inject then run
ps -aux |grep vlc
you will see that it has started two processes. Hitting the kill only kills one of them. I don't know what the solution to that is, if it spawns another process I would have expected that to get killed too.

Maybe the exec node stores only a single PID at a time?

The exec node will not know that the process it started has started another, but I would have expected killing the first to also kill processes it has started. I guess it is due to how cvlc starts the second process.

I use two identical nodes, one for a radio stream the other for a TV stream.
I want them to work at the same time but to be able to stop one of the two when I want.
The stream I sent is that of radio, that of TV is identical

Hmm. So if you start each VLC instance from their respective exec nodes, then trigger the kill message to each exec node, only one will get killed?

When I launch the radio stream, for example, I can kill him with the SIGTERM inject node.
If I restart the radio exec node a few seconds later, and try to kill it with the SIGTERM node, it does not work.
Do you think i make a configuration error?

Ok so you can start and kill each VLC once but if you restart them, they cannot be killed the second time?

As I said, the problem is that the first kill does not kill it properly, it leaves one of the processes running. If you kill that one too then all is well. You may have to do some clever interpretting of the ps command. If you run your flow and then run
ps -axjf|grep vlc
then (I think, you need to check the details) the second column is the process id and the first is that of the parent. So you need to find the line starting with the same pid as the one given by the exec node. Then you can kill the original process via the exec node, and manually kill the other one that it has spawned.

Belay that, a much better way.
If you start the flow and get the pid that the exec node provides (say 1234) then running the command
ps --ppid 1234
gives all the processes started by that one. So you should just be able to kill that process with an explicit kill command and kill the original via the exec node ( or by pid if that is easier).

I confirm that you are right: the processes are not killed correctly because they remain visible and active in pavucontrol.
Below is the return of the command launched in the terminal.

pi@raspberrypi:~ $ ps --ppid 5531
PID TTY TIME CMD
5532 ? 00:00:06 vlc

I am confused because my wife threatens to leave me if we do not immediately go to dinner with friends who are waiting for us! Yet solving this problem is so really important for my project!
Death in the soul, I tell you "see you tomorrow". :grinning:
Thanks a lot for your help.

1 Like

Godspeed!