summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-12-03 13:28:03 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-12-03 13:28:03 -0500
commit999b1164a486f5140310207533a69ab3ec1f467e (patch)
treee3c39b36eb3021f466403c8abfbe9c73176ccaca
parent50c03668d1d81c93d9c540e6a8c45e604068cc45 (diff)
daemon: re-think using read
-rw-r--r--daemon.sh15
1 files changed, 7 insertions, 8 deletions
diff --git a/daemon.sh b/daemon.sh
index 63def36..3fcbc99 100644
--- a/daemon.sh
+++ b/daemon.sh
@@ -8,14 +8,13 @@ get_ident() {
is_running() {
local pidfile=$1
if [[ -f "$pidfile" ]]; then
- cat "$pidfile" | while read pid ident1; do
- ident2="$(get_ident "$pid")"
- if [[ "$ident1" = "$ident2" ]] && [[ -n "$ident2" ]]; then
- return 0
- else
- return 1
- fi
- done
+ read -r pid ident1 <"$pidfile"
+ ident2="$(get_ident "$pid")"
+ if [[ "$ident1" == "$ident2" ]] && [[ -n "$ident2" ]]; then
+ return 0
+ else
+ return 1
+ fi
else
return 1;
fi