Permalink
Browse files

door: remove while true loop around read

There are cases where ./ibutton dies (e.g. because of usb resets), closing
the pipe to ./door, which will cause read to fail instantly. the outer
while true loop caused 100% cpu usage in these cases.

It is recommended to use a regular cronjob to check for ./ibutton and
./door instead and restart them as needed.
  • Loading branch information...
1 parent 899e3de commit 4d7d2d56317e6c140b72beb28f52c0591b22c833 @derf derf committed Jan 20, 2013
Showing with 11 additions and 9 deletions.
  1. +11 −9 door
View
20 door
@@ -1,11 +1,13 @@
#!/bin/sh
-while true; do
- while read REPLY; do
- if [ -f "/root/authorized_ibuttons/$REPLY" ]; then
- /bin/opendoor.py
- else
- sleep 3
- echo "$REPLY" > /tmp/last_failed_ibutton
- fi
- done
+# ibutton.c may die e.g. in case of USB resets. It is recommended to use
+# monitoring / a cronjob to restart ./ibutton | ./door if one of them is no
+# longer running
+
+while read REPLY; do
+ if [ -f "/root/authorized_ibuttons/$REPLY" ]; then
+ /usr/local/bin/opendoor.py
+ else
+ sleep 3
+ echo "$REPLY" > /tmp/last_failed_ibutton
+ fi
done

0 comments on commit 4d7d2d5

Please sign in to comment.