New to ruby,how to make FIFO in ruby?

Thanks,but if I want to create a fifo file in pure ruby way, I mean don’t
need to call “mkfifo”,anyone can tell me how to handle it ?Thanks.

Maggie

===== Original Message From ruby-talk@ruby-lang.org =====

···

Maggie Xiao graced us by uttering:

Is there anyone can tell me how to make FIFO in ruby? I cannot find
the related method? Thanks.

When I ported a Perl script that used (Unix special filetype) FIFOs, I
simply used Kernal::system to call the external executable.

Another option might be to use the mkfifo(3) POSIX call on systems that
support it.

If anyone knows of a more graceful way to accomplish this, I’d be very
interested in hearing it.

Just as a (somewhat anal) optimization/efficiency issue, backticks would
be overkill, as mknod(1)/mkfifo(1) don’t write anything to stdout. It’s
sufficient to run under Kernel::system and check the return value,
rather than run it in backticks and capture output that may not exists
into a variable that may not even be present.

A similar, Perl-related issue can be found here (if you have the perldoc
command):

$ perldoc -q map

or here:

http://www.perldoc.com/perl5.6.1/pod/perlfaq6.html

→ “What’s wrong with using grep or map in a void context?”

Maggie

HTH
Tim Hammerquist

Westley: Why didn’t you wait for me?
Buttercup: Well, you were dead.
– “The Princess Bride”

Hi,

Thanks,but if I want to create a fifo file in pure ruby way, I mean don’t
need to call “mkfifo”,anyone can tell me how to handle it ?Thanks.

Try syscall.
http://www.ruby-lang.org/en/raa-list.rhtml?name=syscall

require ‘syscall’
require ‘sys/stat’
class File
def self.mkfifo(path, mode = 0666)
Syscall.mknod(path, Stat::IFIFO|mode, 0)
end
end
File.mkfifo(“/tmp/foo”)

···

At Fri, 12 Jul 2002 23:18:36 +0900, Maggie Xiao wrote:


Nobu Nakada