darren@bacchus (Darren Friedlein) (04/14/88)
OK - Is there anyone out there that can explain to me how named pipes work (specifically on the UNIXpc)? I understand the concept, but I don't know how to implement them. I believe /dev/lp is one, but I'm not sure. Does each one require a device driver? Does the fact that I use the pty package make things any easier? -Darren /****** /***** {mcnc} Darren G. Friedlein * * /****** * {icus} Rt 4 Box 416, Durham NC 27703 * * * * {ethos} data(bacchus):919/596-7746 * *urham \*****\ * ompany {gladys} voice:919/596-9492 \****** *oftware \***** {bakerst}!bacchus!darren ******/ "I broke a mirror in hy house - I'm supposed to get seven years bad luck but my lawyer thinks he can get me five." -Steven Wright
les@chinet.UUCP (Leslie Mikesell) (04/15/88)
In article <339@bacchus> darren@bacchus (Darren Friedlein) writes: > >OK - Is there anyone out there that can explain to me how named pipes work >(specifically on the UNIXpc)? I understand the concept, but I don't know >how to implement them. I believe /dev/lp is one, but I'm not sure. Does >each one require a device driver? Does the fact that I use the pty package >make things any easier? No, /dev/lp is not a named pipe... ls -l will show the first character of the listing as a 'p' for anything that is a named pipe (also known as a FIFO). /dev/lp is a 'c'haracter device. Create a named pipe with: mknod filename p Then open/read/write redirected I/O and most of the other things that work with files and unnamed pipes can be used with the following differences: A read will block if there is no data available (controlled by O_NDELAY) and a process has the file open for writing. If the FIFO has been opened for writing and no process currently has it open for writing, a read will return EOF when there is no data. A write will block until a process opens the FIFO for reading (again controlled by O_NDELAY). If you want to read the FIFO with a shell script without worrying about EOF every time a process closes it, just make the same program also open the FIFO for writing (even if you don't want to write to it). This will make all reads block until something writes to the FIFO. Les Mikesell ...ihnp4!chinet!les
kevin@kosman.UUCP (Kevin O'Gorman) (04/15/88)
In article <339@bacchus> darren@bacchus (Darren Friedlein) writes: > >OK - Is there anyone out there that can explain to me how named pipes work >(specifically on the UNIXpc)? I understand the concept, but I don't know >how to implement them. I believe /dev/lp is one, but I'm not sure. Does >each one require a device driver? Does the fact that I use the pty package >make things any easier? The only named pipe in the standard UNIX PC stuff is /usr/spool/lp/FIFO, which I have guessed (but don't know) is how 'lp' tells the scheduler there's stuff to print. This exists only when the lp scheduler is running, or has crashed. I found this out doing backups, because cpio would choke on a named pipe in the file system. There's not much documentation on these beasts, but there was a posting a long time ago called '2-d pipes' which used these things to create a more complicated pipeline structure than the straight line usually used. The idea is to make a directory entry with mknod(2), and then have two processes open it, one for reading and one for writing. They are now connected by a pipe, just like the one you get from the pipe(2) call. They are useful primarily when the name of the pipe is agreed by convention (as is the case with /usr/spool/lp/FIFO).