Hi,
I'm running OpenWrt 18.06
I have three scripts.
The main script is "tata.sh" and I have two other scripts that run / kill this script : "tata_start.sh" / "tata_end.sh"
The first script (tata.sh) runs an infiinte loop giving me its PID and PPID:
#!/bin/ash
while :
do
echo "tata : Pid=$$ $(grep PPid /proc/$$/status)"
sleep 10
done
tata_start.sh runs tata.sh in background
#!/bin/ash
echo "$0 : Pid=$$ $(grep PPid /proc/$$/status)"
./tata.sh &
tata_end.sh kills any tata.sh script running in background
#!/bin/ash
echo "$0 : Pid=$$ $(grep PPid /proc/$$/status)"
pgrep -f tata.sh && pkill -f tata.sh
If I execute both of them at the prompt, it works well (tata_start.sh runs start.sh in background and tata_end.sh kills the background tata.sh process)
$> ./tata_start.sh && ./tata_end.sh
./tata_start.sh : Pid=6041 PPid: 413
./tata.sh : Pid=6043 PPid: 1
./tata_end.sh : Pid=6044 PPid: 413
6043
If I run both in a procd init script, I can start the service but then it is stuck when I try to stop it.
#!/bin/sh /etc/rc.common
USE_PROCD=1
start_service(){
/root/tata_start.sh
}
stop_service(){
/root/tata_end.sh
}
I know that there is a procd_instance that I should be using but I just don't understand why the service gets stuck at "flock -n 1000" and doesn't just kill tata.sh and exit.
Thanks