From: Mark Firestone Date: 2003-05-20T20:02:34+09:00 Subject: Re: Named Pipes Cool! I understand a bit more now. Here's what I am doing... Martin Demello and I have written an old style multiline (with threads) BBS in Ruby. It runs on linux. There are lots of old dos games for BBSes that run under, well, dos. So, I got this crazy idea one day... I can run them under dosemu, and pipe the input and output though the BBS program, to the user. I wrote (with some help from the list) a little piece of code that does this with unnamed pipes, which works fine for "regular" apps that use stin and stout, but not for doseum When I am using dosemu, I only get the input... stuff I send to it doesn't get there... It turns out it has a -U switch, that is supposed to make it use named pipes. You specify the pipes on the command line. I wrote a piece of code that should do this, but everything locks. I'm not sure if it is me or this app. Is there a convention regarding where named pipes get placed? Maybe that is part of the problem... I'm putting these in the same directory as the app. maybe that is wrong. Thanks for all your help! Mark At 19:38 20/05/2003 +0900, you wrote: >On Tue, May 20, 2003 at 04:18:13PM +0900, Mark Firestone wrote: > > Ok. Thanks for that. I guess this is going to be trial and error. My > > concern is that i am wasting my time trying to fix something that may be > > working ... and that it could be DOSEMU that isn't... > > > > I need to find a way to test it with something else... Hmmm... > > > > So, I wonder what IO.pipes does? > >A *named* pipe is something you create in the filesystem with 'mkfifo'. One >process can open it for writing, and another process open it for reading. > >$ mkfifo zer >$ ls -l zer >prw-r--r-- 1 brian brian 0 May 20 11:30 zer >^ >| > `this shows it's a named pipe > >I don't think DOS has any concept of named pipes. > >There is no "IO.pipes" that I am aware of, but there is "IO.pipe". This >creates an *unnamed* pipe with two endpoints, already open for reading and >writing - see "man 2 pipe" for the Unix view of this, and >http://www.rubycentral.com/book/ref_c_io.html#IO.pipe >for the Ruby view. > >You could then have two Ruby threads, one reading and one writing to the >same pipe, or you could fork another process (in the latter case >IO.popen("-") is simpler since it does the fork as well as the pipe >creation) > >I don't think 'fork' will work in DOS, but Ruby threads should be fine: > > rd, wr = IO.pipe > Thread.new do > wr.print "Hello world!" > wr.close > end > result = rd.read > rd.close > puts "I got: #{result.inspect}" > >If that doesn't solve your problem, then perhaps you can describe what it is >you're trying to do? > >Regards, > >Brian.