# How to create a pipe file ("mkfifo pipe\_file")

**URL:** <https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240>\
**Category:** Ruby\
**Created:** [January 7, 2010, 8:17pm UTC](https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240 "2010-01-07T20:17:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [January 7, 2010, 8:17pm UTC](https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240/1 "2010-01-07T20:17:39Z")

</div>

Hi, I don’t find the appropriate command to create a “pipe” file in  
Ruby.  
Which is the command to behave as system “mkfifo pipe\_file”?

Thanks.

---

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [January 7, 2010, 9:16pm UTC](https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240/2 "2010-01-07T21:16:47Z")

</div>

El Jueves, 7 de Enero de 2010, IÃ±aki Baz C. escribiÃ³:

> Hi, I don’t find the appropriate command to create a “pipe” file in Ruby.  
> Which is the command to behave as system “mkfifo pipe\_file”?

By the way, is it better to use a pipe\_file or a UNIX socket? both are  
IO  
objects but, is there any advantage in using some of them?

Thanks.

---

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [January 7, 2010, 9:34pm UTC](https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240/3 "2010-01-07T21:34:55Z")

</div>

On 01/07/2010 06:19 PM, Iñaki Baz C. wrote:

> El Jueves, 7 de Enero de 2010, Iñaki Baz C. escribió:
> 
> > Hi, I don’t find the appropriate command to create a “pipe” file in Ruby.  
> > Which is the command to behave as system “mkfifo pipe\_file”?
> 
> By the way, is it better to use a pipe\_file or a UNIX socket? both are IO  
> objects but, is there any advantage in using some of them?

It depends on your usage model: if you need to know every individual  
client then you need to use a socket. If you just can read message  
after message from wherever it came you can use a named pipe. Also,  
IIRC a named pipe signals EOF once a writer has closed its end. So both  
have a quite different usage model…

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [January 7, 2010, 11:42pm UTC](https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240/4 "2010-01-07T23:42:34Z")

</div>

El Jueves, 7 de Enero de 2010, Robert K.  
escribió:\> On 01/07/2010 06:19 PM, Iñaki Baz C. wrote:

> > El Jueves, 7 de Enero de 2010, Iñaki Baz C. escribió:
> > 
> > > Hi, I don’t find the appropriate command to create a “pipe” file in  
> > > Ruby. Which is the command to behave as system “mkfifo pipe\_file”?
> > 
> > By the way, is it better to use a pipe\_file or a UNIX socket? both are IO  
> > objects but, is there any advantage in using some of them?
> 
> It depends on your usage model: if you need to know every individual  
> client then you need to use a socket.

> If you just can read message after message from wherever it came you can use  
> a named pipe.

Yes, this is my case 🙂

---

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [January 8, 2010, 2:15pm UTC](https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240/5 "2010-01-08T14:15:11Z")

</div>

On 7 Jan 2010, at 16:05, Iñaki Baz C. wrote:

> Hi, I don’t find the appropriate command to create a “pipe” file in Ruby.  
> Which is the command to behave as system “mkfifo pipe\_file”?

I see you’ve been asking a lot of questions over the Xmas break which  
seem to amount to “how the heck do I tame Unix from Ruby”. Whilst  
they’re by no means the full answer, take a look at the “Ruby Plumber’s  
Guide” presentations linked from my sig and google the couple of videos  
that accompany them (there’s one from GoRuCo, another from Rails  
Underground, and possibly others too).

There should be enough between them to give you an idea of how to use  
Unix system calls from standard Ruby with syscall and Ruby/DL (or with a  
bit of thought from Ruby/FFI).

Also grab yourself a copy of Marc Rochkind’s “Advanced Unix Programming”  
and then spend a few days with the man pages for your favourite Unix  
distro. Whilst the POSIX calls have the advantage of being fairly  
portable you’ll find most platforms have some cool calls of their own.

Ellie

## Eleanor McHugh Games With Brains [http://slides.games-with-brains.net](http://slides.games-with-brains.net)

raise ArgumentError unless @reality.responds\_to? :reason

---

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [January 8, 2010, 2:23pm UTC](https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240/6 "2010-01-08T14:23:23Z")

</div>

El Viernes, 8 de Enero de 2010, Eleanor McHugh  
escribió:\>

> There should be enough between them to give you an idea of how to use Unix  
> system calls from standard Ruby with syscall and Ruby/DL (or with a bit of  
> thought from Ruby/FFI).
> 
> Also grab yourself a copy of Marc Rochkind’s “Advanced Unix Programming”  
> and then spend a few days with the man pages for your favourite Unix  
> distro. Whilst the POSIX calls have the advantage of being fairly portable  
> you’ll find most platforms have some cool calls of their own.

Thanks a lot, I’m already reading such documentation 🙂

---

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [January 10, 2010, 1:47pm UTC](https://www.ruby-forum.com/t/how-to-create-a-pipe-file-mkfifo-pipe-file/181240/7 "2010-01-10T13:47:31Z")

</div>

On 8 Jan 2010, at 13:22, Iñaki Baz C. wrote:

> > Also grab yourself a copy of Marc Rochkind’s “Advanced Unix Programming”  
> > and then spend a few days with the man pages for your favourite Unix  
> > distro. Whilst the POSIX calls have the advantage of being fairly portable  
> > you’ll find most platforms have some cool calls of their own.
> 
> Thanks a lot, I’m already reading such documentation 🙂

I should add that there’s also a wealth of useful code lurking on Github

- especially amongst Ara T. Howard’s stuff.

Oh, and despite what the docs might say it seems to be perfectly safe  
(at least under mainstream Unix implementations) to load libc with  
either Ruby/DL or Ruby-FFI 🙂

Ellie

## Eleanor McHugh Games With Brains [http://slides.games-with-brains.net](http://slides.games-with-brains.net)

raise ArgumentError unless @reality.responds\_to? :reason
