Code: Select all
vesta/func/remote.sh
The problem with this approach is that the function uses the pidof command to retrieve the PIDs of all running instances of the script. However, the pidof command may return the PID of the current instance of the script as well. This means that the function will always detect itself as a running instance of the script, even if it is the only instance running.
The cause of the issue is the use of the pidof command in the is_procces_running function. The pidof command returns the PIDs of all running instances of a given process, including the current instance. This causes the function to always detect itself as a running instance of the script.
To fix the issue, we need to modify the is_procces_running function to exclude the current instance of the script from the list of running instances. We can do this by filtering out the PID of the current instance from the list of PIDs returned by the pidof command.
Here's the modified code for the is_procces_running function:
Code: Select all
language-sh
is_procces_running() {
SCRIPT=$(basename $0)
CURRENT_PID=$$
for pid in $(pidof -x $SCRIPT); do
if [ $pid != $CURRENT_PID ]; then
check_result $E_INUSE "$SCRIPT is already running"
fi
done
}