mike@ames.arc.nasa.gov (Mike Smithwick) (06/17/88)
[take a line eater to lunch] Ok, like, ya know, I'm trying to work with this pipe device thingy, and it's like, actin' really weird I think. . . I want to have a little background program running all of the time monitoring pipe:. From time to time, stuff will be redirected to it from cli. What is happening is this: I start up foo, the program, and it opens pipe:, then hits "read(fd. . .", and promptly blocks (hangs). It unblocks when I do something like "date > pipe:". After reading the data, it seems to be in a non-blocking mode, so, when there is nothing being sent to pipe:, the read just returns a zero. (This is what I want all of the time.) Now, if I do another redirection to pipe:, like above, I get "CLI error : unable to open redirection file". I can correct that by closing and reopening pipe: inside foo, but that returns me to the blocking problem I get at startup. So the question is, what's really happening? Am I guilty of pipe abuse and should be sent back to flipping burgers at McDonalds, or is there something weird going on that I am unawares of. waiting on pins and needles . . . -- *** mike (starship janitor) smithwick *** "Being a dwarf does have it's shortcomings" [disclaimer : nope, I don't work for NASA, I take full blame for my ideas]
michael@stb.UUCP (Michael) (06/20/88)
Which pipe device are you using? There are at least 2 public domain ones, a third was on the 1.2 disks (non working, alas), there's probably another one on the 1.3 disks (which are still gamma, so it may be bugged). In general, pipes work by having a reader and a writter. The reader will block on reads until either A: A writter writes data, B: All writters close the file Since AmigaDos does not allow duplicating file handles, this really only allows for a single reader and single writter. From your discription, it sounds like the pipe: you are using will only support one pipe at any given time, and as such, your descriptions sound reasonably correct--the reader blocks until data is written, once the writter closes the file and exits, the reader receives length 0 reads, and additional opens are not allowed until the first pipe: is gone. You might want to get one of the other pipe handlers and see if they allow a pipe to be opened multiple times for writting. In any event, the reader will block if there are no writters (at least for any pipe device that wants to maintain resonable compatibility with the definition of unix pipes). (Remember: A pipe should look to a program like a file. When a program reads length 0 from a file, it hits end of file. You haven't hit end-of-pipe until no more writters exist). Hmm, here's something you might try (might work): RUN WAIT > PIPE: 32766 MIN RUN MONITOR COMMAND1 > PIPE: COMMAND2 > PIPE: etc. This might work, or it might not. Michael : --- : Michael Gersten uunet.uu.net!denwa!stb!michael : sdcsvax!crash!gryphon!denwa!stb!michael : What would have happened if we had lost World War 2. Well, the west coast : would be owned by Japan, we would all be driving foreign cars, hmm...