Yang Guan
Yang Guan

Reputation: 81

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?

Upvotes: 7

Views: 4473

Answers (1)

Darshan Rivka Whittle
Darshan Rivka Whittle

Reputation: 34061

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')

Upvotes: 10

Related Questions