Skip to content

Instantly share code, notes, and snippets.

Created April 1, 2014 07:03
Show Gist options
  • Save anonymous/9909175 to your computer and use it in GitHub Desktop.
Save anonymous/9909175 to your computer and use it in GitHub Desktop.
named pipe snippet
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