Skip to content

Commit

Permalink
preload-daemon: no check for already running process
Browse files Browse the repository at this point in the history
Prevent the fork bomb by letting preload child processes know they have
already been run with preload-daemon.
No big advantage to this change, but it is one less place multiple
pi-apps installations in different folders running concurrently could
interfere with one another.
  • Loading branch information
Botspot committed Mar 25, 2024
1 parent 8e3084d commit c6cc35a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 1 addition & 6 deletions etc/preload-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

#runs in the background and refreshes all the list files

#Only one instance of this script should run at a time. If this is removed, preload will form a fairly good fork bomb.
if [ "$(pgrep preload-daemon | wc -l)" -gt 2 ];then
exit 0
fi

DIRECTORY="$(dirname "$(readlink -f "$(dirname "$0")")")"

function error {
Expand Down Expand Up @@ -74,7 +69,7 @@ if [ "$timestamps" != "$(cat "${DIRECTORY}/data/preload/timestamps-preload-daemo

echo "Preload-daemon running..." 1>&2
for folder in $folders ; do
"${DIRECTORY}/preload" "$guimode" "$folder" &>/dev/null
RUNNING_FROM_DAEMON=1 "${DIRECTORY}/preload" "$guimode" "$folder" &>/dev/null
done
echo done 1>&2

Expand Down
4 changes: 3 additions & 1 deletion preload
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,6 @@ else
fi

#preload all categories in background
"${DIRECTORY}/etc/preload-daemon" "$format" &>/dev/null &
if [ "$RUNNING_FROM_DAEMON" != 1 ];then
"${DIRECTORY}/etc/preload-daemon" "$format" >/dev/null &
fi

0 comments on commit c6cc35a

Please sign in to comment.