I have a Bash script that requires some cleanup commands to happens when it gets closed in the console.
Basically the cleanup is a restart command in my Python daemon program (let's call this P), which stops the current process and starts a new one. The Bash script is used to monitor the Python daemon app.
However the problem is that for some reason, it's not launching the program to restart the Python program.
Bash script is located on the desktop of my Raspberry Pi using Raspbian. I am supposed to start this by double-clicking it and selecting Execute in Terminal.
Here is the gist of my code.
function clean_up {
python3 A restart & #stops the python Deamon if running, then start it. (will start if it wasn't running to begin with)
disown
quit
}
trap clean_up SIGINT
trap clean_up SIGTERM
trap clean_up SIGHUP
trap clean_up SIGCHLD
trap clean_up SIGCONT
python3 A stop
... (code to start monitor)
python3 A start ArgumentToHookToMonistor
bashscript doesn't monitor anything - itdisowns it.(trap '' HUP; python3 restart <&3 >&3 2>&3) 3<>/dev/null