Permalink
Browse files

Merge pull request #32 from Maher4Ever/master

Fix a synchronisation bug
  • Loading branch information...
2 parents a331537 + 62b6ca3 commit 99883a00f710a8e0c95cebe9fc4e4d08b0008fd0 @ttilley ttilley committed Apr 4, 2012
Showing with 14 additions and 12 deletions.
  1. +13 −11 lib/rb-fsevent/fsevent.rb
  2. +1 −1 rb-fsevent.gemspec
View
@@ -32,12 +32,14 @@ def watch(watch_paths, options=nil, &block)
end
def run
+ @pipe = open_pipe
@running = true
+
# please note the use of IO::select() here, as it is used specifically to
# preserve correct signal handling behavior in ruby 1.8.
- while @running && IO::select([pipe], nil, nil, nil)
- if line = pipe.readline
- modified_dir_paths = line.split(":").select { |dir| dir != "\n" }
+ while @running && IO::select([@pipe], nil, nil, nil)
+ if line = @pipe.readline
+ modified_dir_paths = line.split(':').select { |dir| dir != "\n" }
callback.call(modified_dir_paths)
end
end
@@ -47,18 +49,18 @@ def run
end
def stop
- if pipe
- Process.kill("KILL", pipe.pid)
- pipe.close
+ unless @pipe.nil?
+ Process.kill('KILL', @pipe.pid)
+ @pipe.close
end
rescue IOError
ensure
- @pipe = @running = nil
+ @running = false
end
if RUBY_VERSION < '1.9'
- def pipe
- @pipe ||= IO.popen("#{self.class.watcher_path} #{options_string} #{shellescaped_paths}")
+ def open_pipe
+ IO.popen("#{self.class.watcher_path} #{options_string} #{shellescaped_paths}")
end
private
@@ -89,8 +91,8 @@ def shellescape(str)
return str
end
else
- def pipe
- @pipe ||= IO.popen([self.class.watcher_path] + @options + @paths)
+ def open_pipe
+ IO.popen([self.class.watcher_path] + @options + @paths)
end
end
View
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.rubyforge_project = "rb-fsevent"
- s.add_development_dependency 'bundler', '~> 1.0.10'
+ s.add_development_dependency 'bundler', '~> 1.0'
s.add_development_dependency 'rspec', '~> 2.5.0'
s.add_development_dependency 'guard-rspec', '~> 0.1.9'

0 comments on commit 99883a0

Please sign in to comment.