From 02fcb9037b4bede761b80aebe1b7ac0aebb63f14 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Tue, 28 Apr 2015 21:07:25 +0200 Subject: [PATCH] Fix startup scripts. Thanks to @Markismus's questions, I realized that some of what i thought was true, wasn't. First, pkill is a terrible idea to check for interpreted scripts. Second, pidof is also potentially not that great for interpreted scripts, because it'll only work with a shebang, and one that is following the Linux syntax. We don't have the full version with the -x to paper over that, so use pgrep -f instead. cf. https://github.com/NiLuJe/koreader/commit/a736a571d221993c410da36bdcd8a1a2bde3f0fa#commitcomment-10948910 for the gory details. --- platform/kindle/koreader.sh | 2 +- platform/kobo/koreader.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index 0d9362b4c..a9dd54b35 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -208,7 +208,7 @@ fi ./reader.lua "$@" 2> crash.log # clean up our own process tree in case the reader crashed (if needed, to avoid flooding KUAL's log) -if pkill -0 reader.lua ; then +if pidof reader.lua > /dev/null 2>&1 ; then logmsg "Sending a SIGTERM to stray KOreader processes . . ." killall -TERM reader.lua fi diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index 91539f97a..3983477e7 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -89,7 +89,7 @@ else # if we were called from advboot then we must reboot to go to the menu # NOTE: This is actually achieved by checking if KSM is running: # This might lead to false-positives if you use neither KSM nor advboot to launch KOReader *without nickel running*. - if ! pidof ksmhome.sh > /dev/null 2>&1 ; then + if ! pgrep -f ksmhome.sh > /dev/null 2>&1 ; then reboot fi fi