From 1b208ec3f5f303ed93d958b3d8f6d5732cf1a245 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 01 Jun 2018 22:56:37 -0400 Subject: 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. --- 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 } -- cgit v0.9.1