Skip to content

Commit

Permalink
abnormal termination fails silently + burns cpu
Browse files Browse the repository at this point in the history
fix: use @pipe.read_nonblock(1) instead of @pipe.read(1)
fix: rescue EOFError (raised by #read_nonblock) and wait 1 seconds before iterating over
  • Loading branch information
saluzafa committed Feb 28, 2018
1 parent 0b8b736 commit b86389e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rb-fsevent/fsevent.rb
Expand Up @@ -52,7 +52,7 @@ def run
found_length = false

while reading_length
byte = @pipe.read(1)
byte = @pipe.read_nonblock(1)
if "#{byte}" =~ /\d/
length << byte
found_length = true
Expand All @@ -79,6 +79,8 @@ def run
callback.call(modified_paths, decoded)
end
end
rescue EOFError
sleep 1
rescue Interrupt, IOError, Errno::EBADF
ensure
stop
Expand Down

0 comments on commit b86389e

Please sign in to comment.