STREAMS-UX Programmer's Guide (February 2007)

Multiplexing
Persistent Links
Chapter 5
118
Persistent Links
When I_LINK and I_UNLINK ioctls are used, the file-descriptors associated with the upper stream need to
be active through out the operation of the multiplexor configuration. Closing the controlling stream will
unplumb the multiplexor configuration. It may not be desirable to keep an application process active only to
hold the multiplexor configuration together. This is resolved by using persistent links below a multiplexor. A
persistent link is similar to a STREAMS multiplexor link, except that a process is not needed to maintain the
links. After the multiplexor configuration has been set up, the process may close all associated file descriptors
and exit. The multiplexor will remain intact.
Persistent links are created and dismantled with two ioctls:
I_PLINK
I_PUNLINK
close(2) and I_UNLINK cannot disconnect a multiplexor configuration created through the I_PLINK ioctl.
Creating Persistent Links
The format of the I_PLINK is:
ioctl(muxfd, I_PLINK, drvfd);
muxfd
Is the stream connected to the multiplexing driver.
drvfd
Is the stream to be linked below the multiplexing driver.
The ioctl I_PLINK returns the muxid of the configuration. The muxid can be stored in a file or passed to
another process for unplumbing the persistently linked streams later.
The following code snippet will create the persistent link configuration.
...
muxfd = open("/dev/mux", O_RDWR);
drvfd = open("/dev/drv", O_RDWR);
muxid = ioctl(muxfd, I_PLINK, drvfd);
/* Save the muxid in file for later use */
...
Figure 5-3, “Multiplexor Before I_PLINK,” shows how open() creates a stream between the device and the
stream head. Figure 5.4 shows a multiplexor after I_PLINK.