Stream Pipes: how to use them on V.3/386
Jerry Merlaine
jom at belltec.UUCP
Sun Sep 24 09:47:14 AEST 1989
If you want to use UNIX V.3 Stream Pipes (like you're not supposed to),
here's how: call the following routine instead of pipe(2) (look it up).
You will get a pair of cross-connected read/write Streams file descriptors.
FDINSERT's are covered in streams(7) in the UNIX manual.
If you want your own stream pipe, get the Streams Programmer's Guide
and type in the loopback driver sources. It's Fun And Easy!
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stream.h>
#include <sys/stropts.h>
strpipe(pv)
int pv[2];
{
struct strfdinsert fdi;
pv[0] = open("/dev/spx", 2);
pv[1] = open("/dev/spx", 2);
if (pv[1] < 0) {
close(pv[1]);
if (pv[0] >= 0)
close(pv[0]);
return -1;
}
if (pv[0] < 0)
return -1;
fdi.ctlbuf.buf = (char *) pv;
fdi.ctlbuf.len = 4;
fdi.databuf.buf = 0;
fdi.databuf.len = -1;
fdi.offset = 0;
fdi.fildes = pv[1];
fdi.flags = 0;
if (ioctl(pv[0], I_FDINSERT, &fdi) < -1) {
close(pv[0]);
close(pv[1]);
return -1;
}
return 0;
}
More information about the Comp.unix.wizards
mailing list