Skip to content

Commit f04bd39

Browse files
committed
Merge pull request #56 from Telmate/master
Fix a bug in jruby env where pid is not a valid pid.
2 parents 7e96864 + d803637 commit f04bd39

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/rb-fsevent/fsevent.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,23 @@ def run
5252

5353
def stop
5454
unless @pipe.nil?
55-
Process.kill('KILL', @pipe.pid)
55+
Process.kill('KILL', @pipe.pid) if process_running?(@pipe.pid)
5656
@pipe.close
5757
end
5858
rescue IOError
5959
ensure
6060
@running = false
6161
end
6262

63+
def process_running?(pid)
64+
begin
65+
Process.kill(0, pid)
66+
true
67+
rescue Errno::ESRCH
68+
false
69+
end
70+
end
71+
6372
if RUBY_VERSION < '1.9'
6473
def open_pipe
6574
IO.popen("'#{self.class.watcher_path}' #{options_string} #{shellescaped_paths}")

0 commit comments

Comments
 (0)