Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create named pipe in Ruby

I am trying to create a named pipe inside Ruby. Besides using the system command (system("mkfifo #{pipe_name}")), is there a native Ruby function allowing me to do this?

like image 444
Yang Guan Avatar asked Jun 22 '13 05:06

Yang Guan


Video Answer


1 Answers

Current versions of Ruby (starting with 2.3.0) now have a native File::mkfifo:

File.mkfifo('pipe_name')

Old answer for older versions of Ruby:

I don't believe there's anything fully native, but there's the mkfifo gem.

Install like this:

gem install mkfifo

Then use like this:

require "mkfifo"
File.mkfifo('pipe_name')
like image 170
Darshan Rivka Whittle Avatar answered Sep 19 '22 06:09

Darshan Rivka Whittle