summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2018-06-01 22:56:37 (EDT)
committer P. J. McDermott <pj@pehjota.net>2018-06-04 01:34:26 (EDT)
commit1b208ec3f5f303ed93d958b3d8f6d5732cf1a245 (patch)
tree19db9ae421d74ccfd07237019baf0c9c578996bf
parent5feae401e3b03cefa1193b2b73fe919990aca016 (diff)
downloadhomerc-1b208ec3f5f303ed93d958b3d8f6d5732cf1a245.zip
homerc-1b208ec3f5f303ed93d958b3d8f6d5732cf1a245.tar.gz
homerc-1b208ec3f5f303ed93d958b3d8f6d5732cf1a245.tar.bz2
bin/rc: Close and reopen RC FIFO to make read block
Otherwise, after every command is read and handled, the read utility immediately returns failure due to EOF on every call until another command is written to the RC FIFO, causing the listening loop to become busy and burn CPU time.
-rwxr-xr-xbin/rc4
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/rc b/bin/rc
index 4ce2fdb..ae77113 100755
--- a/bin/rc
+++ b/bin/rc
@@ -145,7 +145,7 @@ listen()
local arg=
while :; do
- if read -r magic cmd arg; then
+ if read -r magic cmd arg 0<"${rc_fifo}"; then
case "${magic}" in "${MAGIC}");; *) continue;; esac
case "${cmd}" in
'beg' | 'end')
@@ -168,7 +168,7 @@ listen()
;;
esac
fi
- done 0<"${rc_fifo}"
+ done
return 0
}