From: Joe Wreschnig Date: 2002-07-14T13:28:51+09:00 Subject: Re: new to ruby,how to make FIFO in ruby? --=-vzKP8pco2EQ7105i5xhQ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Augh! I accidentally bumped send before I was done: class File def self.mkfifo(name, mode=3D"0600", open_mode=3D"rw") if ! File.writeable? File.dirname(name) raise Errno::EACCES, "No such directory" end if File.exists? name and File.pipe? name # Leftover from before File.delete name end if ! File.exists? name system("mkfifo", "--mode=3D" + mode, name) @@created_fifos << name end return File.open(name, open_mode) end def self.delete_fifos @@created_fifos.each { |fifo| File.delete fifo } end end This code doesn't work perfectly (if the file exists and is *not* a FIFO, it will just open the file normally, which was intended behavior for my program, but probably not for yours). And the File.delete_fifos code is probably not mandatory, but usually programs want to clean up their FIFOs when they exist. Also, you might not want it to return the file, in case you want to do your own stuff to make it non-blocking, etc. --=20 - Joe Wreschnig - http://www.sacredchao.net "What I did was justified because I had a policy of my own... It's okay to be different, to not conform to society." -- Chen Kenichi, Iron Chef Chinese --=-vzKP8pco2EQ7105i5xhQ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQA9MP4ATFkUq7Drx3cRAglZAKCnImrTq39z9vGE+eCvyMU5qayOhQCfbHpS MWAliG2bAsJhReA00o6LN18= =kTdr -----END PGP SIGNATURE----- --=-vzKP8pco2EQ7105i5xhQ--