# Exec node creating two processes

**URL:** <https://discourse.nodered.org/t/exec-node-creating-two-processes/43155>\
**Category:** General\
**Created:** [25 March 2021 00:11 UTC](https://discourse.nodered.org/t/exec-node-creating-two-processes/43155 "2021-03-25T00:11:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cocothedoges](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cocothedoges/32/39246_2.png) [@cocothedoges](https://discourse.nodered.org/u/cocothedoges)\
**Post date:** [25 March 2021 00:11 UTC](https://discourse.nodered.org/t/exec-node-creating-two-processes/43155/1 "2021-03-25T00:11:49Z")

</div>

Hi guys,

Im trying to place a switch to on/off my rPI =\> [twitch.tv](http://twitch.tv) stream. The flow:

```auto
[{"id":"bcea7856.3d9df8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"32b7b5b1.ee028a","type":"toggle","z":"bcea7856.3d9df8","name":"","onOffTopic":"","onValue":"true","onType":"bool","offValue":"false","offType":"bool","toggleTopic":"","toggleValue":"","toggleType":"str","passOnOff":"always","x":390,"y":100,"wires":[["aabe67a3.1a63a8"]]},{"id":"496b7ee3.9a249","type":"ui_switch","z":"bcea7856.3d9df8","name":"twitch button","label":"Twitch.tv","tooltip":"","group":"a281b975.ebda78","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"x":150,"y":100,"wires":[["32b7b5b1.ee028a"]]},{"id":"aabe67a3.1a63a8","type":"switch","z":"bcea7856.3d9df8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":100,"wires":[["5c1b9d80.41d054"],["878cf0e2.cb56"]]},{"id":"5c1b9d80.41d054","type":"exec","z":"bcea7856.3d9df8","command":"raspivid -n -t 0 -w 1920 -h 1080 -b 3500000 -fps 30 -o - | ffmpeg -re -i - -input_format h264 -vcodec copy -an -f flv \"rtmp://mad.contribute.live-video.net/app/XXXXX\"","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"ffmpeg","x":820,"y":60,"wires":[[],[],[]]},{"id":"878cf0e2.cb56","type":"change","z":"bcea7856.3d9df8","name":"set to pid","rules":[{"t":"set","p":"payload","pt":"msg","to":"pid","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":140,"wires":[["59538706.2fbb58"]]},{"id":"59538706.2fbb58","type":"exec","z":"bcea7856.3d9df8","command":"kill ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":970,"y":140,"wires":[[],[],[]]},{"id":"259af9f7.6627d6","type":"status","z":"bcea7856.3d9df8","name":"","scope":["5c1b9d80.41d054"],"x":140,"y":180,"wires":[["79129e0c.3eaa8"]]},{"id":"79129e0c.3eaa8","type":"function","z":"bcea7856.3d9df8","name":"get pid","func":"if(msg.status.text){\n let pid = msg.status.text.split(':');\n msg.payload = pid[1];\n return msg;\n} else {\n return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":180,"wires":[["cbe8f9da.101a08"]]},{"id":"cbe8f9da.101a08","type":"change","z":"bcea7856.3d9df8","name":"","rules":[{"t":"set","p":"pid","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":180,"wires":[[]]},{"id":"a281b975.ebda78","type":"ui_group","name":"MOIST","tab":"2f7ea51a.3ab7ea","order":2,"disp":true,"width":"6","collapse":false},{"id":"2f7ea51a.3ab7ea","type":"ui_tab","name":"DHT","icon":"dashboard","disabled":false,"hidden":false}]

```

When I run:

> pi@pi2:~/twitch $ ps aux | grep raspi  
> pi 1662 0.4 0.2 7672 2540 ? S 00:58 0:00 /bin/bash -c raspivid -n -t 0 -w 1920 -h 1080 -b 3500000 -fps 30 -o - | ffmpeg -re -i - -input\_format h264 -vcodec copy -an -f flv "rtmp://mad.contribute.live-video.net/app/XXXXX"  
> pi 1663 0.8 0.2 63136 1944 ? Sl 00:58 0:00 raspivid -n -t 0 -w 1920 -h 1080 -b 3500000 -fps 30 -o -

and the status node is returning only the first PID. Could you help me identify what are these two process?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 March 2021 07:46 UTC](https://discourse.nodered.org/t/exec-node-creating-two-processes/43155/2 "2021-03-25T07:46:48Z")

</div>

One is the /bin/bash process of the shell running the command. The other is the raspivid process itself.

That's entirely normal to see.

---

<div class="post-metadata">

**Author:** ![cocothedoges](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cocothedoges/32/39246_2.png) [@cocothedoges](https://discourse.nodered.org/u/cocothedoges)\
**Post date:** [25 March 2021 08:55 UTC](https://discourse.nodered.org/t/exec-node-creating-two-processes/43155/3 "2021-03-25T08:55:30Z")

</div>

In order to get rid of process IDs I'm thinking about to use the command as a service, then do something like:  
`service streaming start/stop`  
Do you have another better workaround? Is there any way to catch the raspivid processID itself?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 May 2021 08:55 UTC](https://discourse.nodered.org/t/exec-node-creating-two-processes/43155/4 "2021-05-24T08:55:58Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
