Created
August 12, 2011 12:13
Revisions
-
vpereira created this gist
Aug 12, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ require 'fcntl' require 'eventmachine' #what is needed #mkfifo mypipe #that everything written thru the pipe have a "\n" #ex: echo "foobar\n" > mypipe #HPO = Handle Pipe Output module HPO def notify_readable puts @io.readlines end def unbind EM.next_tick do data = @io.read puts dat end end end EM.run { fd = IO.sysopen('mypipe',Fcntl::O_RDONLY|Fcntl::O_NONBLOCK) #i think i dont have to repeat the open mode but egal myIO = IO.new(fd,Fcntl::O_RDONLY|Fcntl::O_NONBLOCK) fdmon = EM.watch myIO, HPO fdmon.notify_readable = true }