Created
April 1, 2014 07:03
-
-
Save anonymous/9909175 to your computer and use it in GitHub Desktop.
named pipe snippet
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 characters
def run | |
# create and intialize named pipe | |
Util.create_pipe :to_daemon | |
#pipe_dummy = File.open( Util::TO_DAEMON_PATH , "w") | |
pipe = File.open( Util::TO_DAEMON_PATH , File::RDONLY | File::NONBLOCK) | |
# main loop | |
read_fds = [] | |
read_fds.push pipe | |
p pipe.fileno | |
while true do | |
if IO.select(read_fds, [], [], 3) | |
actions = Marshal::load pipe.gets | |
parse_actions actions | |
else | |
puts "nothing happening.." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment