lib/dtas/sigevent/pipe.rb in dtas-0.11.0 vs lib/dtas/sigevent/pipe.rb in dtas-0.12.0

- old
+ new

@@ -1,26 +1,27 @@ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org> # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) # used in various places for safe wakeups from IO.select via signals # A fallback for non-Linux systems lacking the "sleepy_penguin" RubyGem +require_relative 'nonblock' class DTAS::Sigevent # :nodoc: attr_reader :to_io def initialize - @to_io, @wr = IO.pipe + @to_io, @wr = DTAS::Nonblock.pipe + @rbuf = '' end def signal @wr.syswrite('.') rescue nil end def readable_iter - begin - @to_io.read_nonblock(11) + case @to_io.read_nonblock(11, @rbuf, exception: false) + when :wait_readable then return :wait_readable + else yield self, nil # calls DTAS::Process.reaper - rescue Errno::EAGAIN - return :wait_readable end while true end def close @to_io.close