There are two ways to create a stream pipe under SVR4 (that is, a pipe that is full-duplex and allows descriptors to be passed across it):

  1. pipe(), and
  2. socketpair().

There are two ways to pass a descriptor under SVR4:

  1. The I_SENDFD and I_RECVFD ioctls, and
  2. The sendmsg() and recvmsg() system calls.

Under previous releases of SVR4 these were all interchangeable. The implementation of sockets within the Solaris 2.6 kernel has changed from all previous Solaris 2.x releases and sockets no longer possess all the properties of a stream. Portable code must not assume the streams properties of sockets in SVR4.

The file lib.svr4/spipe.c in the source code for the book calls pipe and the two files lib.svr4/{send,recv}fd.c call ioctl. This is the recommended way under SVR4.

Alternately, under Solaris 2.x you can call socketpair and then sendmsg and recvmsg, but you need to change what files are built into the libmisc.a library to do this.

On a Berkeley-derived kernel (e.g., 4.xBSD and SunOS 4.1.x), you must call socketpair and then sendmsg and recvmsg.

There are reports of people using the file lib.svr4/spipe.socket.c (which calls socketpair() under Solaris 2.6, and then trying to use the I_SENDFD ioctl to pass a descriptor. This no longer works.