pgf wrote:
> Just a nit. This line, from your script, does _not_ create the pidfile
> using sudo:
> >
Code:
--------------------
> > sudo /bin/echo "$PID" > $PIDFILE
>
--------------------
> >
>
Ooh, thank you - I did wonder about that. Thanks for the tip about
tee.
pgf wrote:
>
> I still don't believe that "kill" will do anything different than
> /bin/kill, given the two are running in an identical environment. (I
> also don't believe you should be using "-9" everywhere. Squeezelite
> dies perfectly happily with a plain "kill". Using -9 is a bad habit.)
>
More good advice, thank you. But why is it a bad habit?
pgf wrote:
>
> I do have a couple of other comments on and questions about your script,
> if you don't mind. Not that I see anything explicitly wrong, but maybe
> they can be simplified, and simpler code is easier and safer.
>
> First:
> Is there any reason not to just use the shell to find the binary? And,
> why does it matter if it's a symlink.
>
I copied this code from the init.d script. I believe it uses this
approach because of the pCP option to use a bespoke squeezelite binary
instead of the supplied one. Not sure about the symlink stuff.
pgf wrote:
>
> Second:
> Anything wrong with letting the shell tell you the PID? That's what $!
> is for. It always contains the pid of the last process put into the
> background.
>
Yeah, that's my code. And I didn't know better. Now I do :)
pgf wrote:
>
> Lastly, even though you're no longer using the init.d script to
> start/stop the daemon, you're still using it to check the daemon's
> status. But all it does when you ask, is checks to see if the pidfile
> exists. You should also also check to see if the process represented by
> that pidfile exists. You can do that with the "-0" option to kill:
>
The init.d script does check whether a process with the same PID as the
one in the pidfile is running:
Code:
--------------------
status)
# Check if our squeezelite daemon is running.
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
PIDS=`/bin/busybox pgrep $DAEMON | awk '{printf "%s ",
$1}'`
for GOTPID in $PIDS; do
if [ x"$GOTPID" = x"$PID" ]; then
echo "$PNAME is running. PID=$PID"
exit 0
fi
done
fi
echo "$PNAME not running."
exit 1
;;
--------------------
I think this approach allows for the possibility that a user might start
a second squeezelite process via a command line, e.g. a bluetooth
player.
pgf wrote:
> Anyway, I'm sure you'll figure out your problem. You set yourself a
> lofty goal when you started this project, and you've done well so far!
>
I'm more and more starting to think that your approach would be a better
way to do this! As a user command, it would probably avoid all the
issues around the start-stop-daemon behaving differently under udev.
------------------------------------------------------------------------
chill's Profile: http://forums.slimdevices.com/member.php?userid=10839
View this thread: http://forums.slimdevices.com/showthread.php?t=113661
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix