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

**URL:** https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896
**Category:** General
**Created:** [6 June 2020 14:16 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896 "2020-06-06T14:16:30Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [6 June 2020 14:16 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/1 "2020-06-06T14:16:30Z")

</div>

It's been two weeks since i battle with VLC on raspberry pi 3B to find a command to put in an exec node in order to close this application.  
After searching the Raspberry, Debian, Ubuntu ... and VLC (!) forums, as well as this one, I still cannot close VLC other than with "killall vlc" when I would like to be able to close one by one my 2 simultaneous instances of VLC (one for TV, the other for radio).  
In fact, I have two problems:  
-1- The vlc: // quit command given by VLC does not work or I do not know how to use it.  
-2- I found on the forum a way to raise the pid of each instance in the flow to send it as an argument to the closing exec node, but I have the impression that I don't know how to write the right command.  
Here is what I do in this Exec node but it doesn't work:  
Comand: kill vlc  
Argument: PID  
Input : SIGKILL, SIGTERM, SIGHUP

To tell you the truth, I don't know anything about programming and I'm new to Nodered.

Any help will be a thousand times welcome and thank you to the leaders of this forum who help newbie like me to progress!

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [6 June 2020 15:33 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/2 "2020-06-06T15:33:52Z")

</div>

I believe the idea was to replace PID with the numerical process ID of the VLC instance you want to kill. The difficulty here is how to know which one is which. That at least I cannot answer right of the bat...

But when a command is started the process ID can be read and stored to a file for example. Google might give clues.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [6 June 2020 15:37 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/3 "2020-06-06T15:37:45Z")

</div>

luckily the exec node will report it in it's status - so you can use a status node to grab it, then store it in context for use later. Or indeed if you have two separate exec nodes for each, then sending a msg.kill to the one you want will kill that one only.

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [6 June 2020 15:38 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/4 "2020-06-06T15:38:54Z")

</div>

Ah of course if the VLC's are started from Node-RED.

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [6 June 2020 15:44 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/5 "2020-06-06T15:44:21Z")

</div>

Yes vlc is started from nodered.

I use two exec nodes: one to launch each instance. I therefore have the pid of each one that I recover thanks to a status node + a function node (which I found on this forum) from which I transform the payload into flow.pid with a change node.  
Therefore, an exec node with the kill command and the pid as an argument should do the job, but that is not the case.

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [6 June 2020 15:46 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/6 "2020-06-06T15:46:29Z")

</div>

Does the kill command work with the PID shown in Node-RED if you run it from a terminal window?

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [6 June 2020 15:48 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/7 "2020-06-06T15:48:02Z")

</div>

> [@ristomatti](#):
>
> and work with the PID shown in Node-RED if you run it from a terminal window?

I try immediately

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [6 June 2020 16:01 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/8 "2020-06-06T16:01:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [6 June 2020 16:01 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/9 "2020-06-06T16:01:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [6 June 2020 16:03 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/10 "2020-06-06T16:03:03Z")

</div>

What command are you using to start vlc?

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [6 June 2020 16:03 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/11 "2020-06-06T16:03:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [6 June 2020 16:08 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/12 "2020-06-06T16:08:12Z")

</div>

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")

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [6 June 2020 16:14 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/13 "2020-06-06T16:14:32Z")

</div>

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

In case you've missed:

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [6 June 2020 16:20 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/14 "2020-06-06T16:20:55Z")

</div>

This process works on the first kill and not the second

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [6 June 2020 16:27 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/15 "2020-06-06T16:27:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [6 June 2020 16:37 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/16 "2020-06-06T16:37:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [6 June 2020 16:38 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/17 "2020-06-06T16:38:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [6 June 2020 16:40 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/18 "2020-06-06T16:40:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.nodered.org/u/Laurent)
#### Post date: [6 June 2020 16:41 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/19 "2020-06-06T16:41:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [6 June 2020 16:46 UTC](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896/20 "2020-06-06T16:46:48Z")

</div>

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?

[Next page](https://discourse.nodered.org/t/close-one-after-one-with-the-exec-node-the-2-instances-of-vlc-displayed/27896.md?page=2)
