Unable to Kill the Process using EXEC Node in "Raspberry PI" though it is showing "KILLED"

Hi All,
In RaspberryPi, I used the EXEC node to run a Python script, and I able to Kill the EXEC node but the script is running background that is the script running process is not killed. We tried to find using Command Window, Then we found that there are two Process IDs (PID) are generating while I run the Command in EXEC node.
How can I Kill two PIDs at a Time..? or
Any command used to Kill the Process using EXEC node in Raspberry Pi..?

Are you running a recent version of node-red? There was a problem fixed a few months ago to do with killing processes in the exec node. I suggest upgrading to the latest to see if it fixes it, unless that is a problem for you.

What is the exact command you are executing? Kill can be quirky based on how the given process accepts signals (or not).

I don't think she(?) is using a command, I assumed she was sending a Kill message to the Exec node.

Oh, yeah... I was thinking CLI kill via exec node.

The fix was to use bash if available for the exec node on linux as dash which is symlinked to be the standard on some distributions doesn’t propagate the kill to the process group. So it would be interesting to know the version of nodered @Sandy is running. It would also be important to know what kind of python script you are running because there are some async python things which run detached and wont be killed if the spawning script dies i think. But its been a long time since I ve written any python code :see_no_evil:


1 Like

SIGKILL is the command I used to kill. To be Specific I used "sudo python filename.py(with path)" to run the Script But The Process IDs are generating for "sudo python filename.py(with path)" along with other PID for the process "python filename.py(with path)" which is the default running background.

And the answer to the questions about which version of node-red you are running?
See at the bottom of the hamburger menu.

Ok just tested two simple python scripts one running threading with a daemon thread and another one running an asyncio task and I can kill either no problem with a msg.kill of SIGTERM both in exec and spawn mode in the latest nodered version. So please do tell us which version of nodered you have installed and if you are using the exec node in spawn or exec mode? You can find it easily here:

Did you see the suggestion that you upgrade to the latest node red version? You can do that by running the pi upgrade script from the node red docs.

1 Like

I second this. I just had a look and the above mentioned fix wasn’t merged till node-red 1.1.0 so its likely that an update to a current nodered version would fix it.

Upgrading the Node-Red Version and using Other Exec Node where Command is "sudo pkill python"

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