-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Only here to satisfy my OCD ;p
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 pidof reader.lua > /dev/null 2>&1 ; then | ||
if pkill -0 reader.lua ; then | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
NiLuJe
Author
Owner
|
||
logmsg "Sending a SIGTERM to stray KOreader processes . . ." | ||
killall -TERM reader.lua | ||
fi | ||
|
11 comments
on commit a736a57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, still don't get it.
I understand the reason why ksmhome.sh fails.
However, I still don't see why starting a script with #!/bin/sh
is different from starting it with #!.luajit
other than apparently luajit isn't seen as the master binary, but reader.lua is. Both use the shebang syntax, so both call a binary and are added as interpreter directive.
The only real difference that I see, is that the path passed is identical to the path of the binary in the case of luajit.
Got it Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, pkill & pidof both behave the same way, so this is still broken.
Thanks for making me look at this again.
We need to use pgrep -f to match the full command-line, since we don't have the -x flag of procps's pidof to do that.
Utterly confused a to why it also fails to catch it when using a shebang, though, which means I need to double-check how my Kindle behaves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just read ksmhome.sh
and it starts with a shebang, too. I assumed it would have been called via /bin/sh ksmhome.sh
, because then your explanation made sense, but now it doesn't anymore.
Ah, but I just refreshed and see that there is another problem...
Based on the wiki I assume it fails, because of the shebang. There is no other way those scripts are called. Just read that the whole shebang was introduced to let the scripts appear when you run a ps command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guys, *nix is weird.
#!/bin/sh
echo "pidof test.sh: $(pidof test.sh)"
pkill -0 test.sh &>/dev/null
echo "pkill -0 test.sh: $?"
echo "pgrep -f test.sh: $(pgrep -f test.sh)"
echo "Wheee."
->
[root@kindle root]# sh test.sh
pidof test.sh:
pkill -0 test.sh: 1
pgrep -f test.sh: 11905
Wheee.
[root@kindle root]# ./test.sh
pidof test.sh: 11909
pkill -0 test.sh: 1
pgrep -f test.sh: 11909
Wheee.
Vs.
# !/bin/sh
echo "pidof test.sh: $(pidof test.sh)"
pkill -0 test.sh &>/dev/null
echo "pkill -0 test.sh: $?"
echo "pgrep -f test.sh: $(pgrep -f test.sh)"
echo "Wheee."
[Notice the space between # and !]
->
[root@kindle root]# sh test.sh
pidof test.sh:
pkill -0 test.sh: 1
pgrep -f test.sh: 12304
Wheee.
[root@kindle root]# ./test.sh
pidof test.sh:
pkill -0 test.sh: 1
pgrep -f test.sh: 12308
Wheee.
TL;DR: spaces are evil. I remember being told that that shebang syntax with an extra space was more portable (and I happened to be using it since that's what my VIM config automagics when creating a .sh), but that's sneaky as fuck.
TL;DR²: pkill is a terrible idea to check for interpreted scripts, shebang or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I have no idea how ksmhome.sh is actually run, I'll switch to pgrep, it appears to be less prone to fuckery ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amen to that.
You left me confused as hell, but that's how I started, so that's no biggie.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because I managed to paste the same script twice, ooops. Edited the post, it should make (slightly) more sense now ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And thanks for the wiki link, that sheds some light on my portability comment regarding that extra space (spoiler: it's horseshit, or at the very least no-one has needed to care about it since the 1980s ;p).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact:
#! /bin/sh
behaves properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the meantime, I'll go fix my VIM config ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So are you going with "#!/wtf" or "#! /wtf" :P
Why is this different from pkilling an sh-script? Or was this earlier than your discussion with Tshering?