Created
September 20, 2009 21:26
-
-
Save danielsdeleo/189934 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "eventmachine" | |
require "fileutils" | |
module Handler | |
def file_modified | |
raise "iamfail, hear me roar" | |
puts "#{path} modified" | |
end | |
def file_moved | |
puts "#{path} moved" | |
end | |
def file_deleted | |
puts "#{path} deleted" | |
end | |
def unbind | |
puts "#{path} monitoring ceased" | |
end | |
end | |
FileUtils.touch("/tmp/fwtest") | |
EM.kqueue = true | |
EM.run do | |
watcher = EM.watch_file("/tmp/fwtest", Handler) | |
raise "failz" | |
Kernel.system("echo 'failtime' >> /tmp/fwtest") | |
EM.add_timer(1) do | |
watcher.stop_watching | |
EM.stop | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) run ./filewatch_test.rb | |
Starting program: /opt/local/bin/ruby ./filewatch_test.rb | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries .... done | |
/tmp/fwtest monitoring ceased | |
Program received signal EXC_BAD_ACCESS, Could not access memory. | |
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000022 | |
0x00007fff84719f80 in std::_Rb_tree_increment () | |
(gdb) bt | |
#0 0x00007fff84719f80 in std::_Rb_tree_increment () | |
#1 0x00000001003bbce6 in EventMachine_t::~EventMachine_t () | |
#2 0x00000001003b33d2 in evma_release_library () | |
#3 0x00000001003c3129 in t_release_machine () | |
#4 0x0000000100028e10 in rb_call0 () | |
#5 0x000000010002914b in rb_call () | |
#6 0x00000001000226c1 in rb_eval () | |
#7 0x00000001000257dc in rb_eval () | |
#8 0x0000000100025258 in rb_eval () | |
#9 0x0000000100028d33 in rb_call0 () | |
#10 0x000000010002914b in rb_call () | |
#11 0x000000010002252b in rb_eval () | |
#12 0x0000000100025c08 in rb_eval () | |
#13 0x000000010003505b in ruby_exec_internal () | |
#14 0x0000000100035098 in ruby_exec () | |
#15 0x00000001000350c0 in ruby_run () | |
#16 0x0000000100000ee4 in main () | |
(gdb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment