SysV pipes - STREAMS?

From: Arnar M. Hrafnkelsson <amh_at_mbl.is>
Date: Wed, 21 Jul 1999 03:02:53 +0000

   Hi managers - My name is Arnar M. Hrafnkelsson...

My problem is as follows - I need to open a file in
one program and send an open fd to another process.
I have code that works supposedly on Svr4 compliant systems.
I've tested it on solaris 2.6 and it works fine there.

Under SVR4 open fds are passed over pipes (which are usually
STREAMS).

The manpage for pipe() on DU is very strange:

DESCRIPTION

  The pipe() function creates a unidirectional interprocess channel
called a
  pipe, and returns two file descriptors, filedes[0] and filedes[1]. The
file
  descriptor specified by the filedes[0] parameter is opened for reading
and
  the file descriptor specified by the filedes[1] parameter is opened
for
  writing.

and then later:

System V Compatibility

  The pipe() function creates an interprocess channel called a pipe and
  returns two file descriptors, filedes[0] and filedes[1]. Both file
  descriptors are STREAMS based and are bidirectional.


Which applies normally?

anyway the problem is basically creating a stream with pipe() (or
something
now).

the following program (compiled with: gcc -o tst tst.c)

#include <unistd.h>
#include <stdio.h>
int main() {
        int fds[2]; printf("%d=pipe()\n",pipe(fds));
        printf("fds=[%d,%d]\n",fds[0],fds[1]);
        printf("stream: [%d,%d]\n",isastream(fds[0]),isastream(fds[1]));

        return 0;
}

prints (under solaris 2.6):
0=pipe()
fds=[3,4]
stream: [1,1]

but under DU it prints:
0=pipe()
fds=[3,4]
stream: [0,0]

So the fds returned are BSD type pipes. not the Bidirectional types
provided by Sysv streams.
In case you are wondering if I should be using unix domain sockets A la
BSD I found this
in the streamio manpage on DU:

 I_SENDFD Requests the Stream referred to by fildes to send a message
            M_PASSFP to the Stream head at the other end of a Stream
pipe.
            The file pointer corresponds to the value of arg, which
specifies
            an open file descriptor.
            etc...

So if anyone has any ideas how to get this working - all help is
appreciated.
Received on Wed Jul 21 1999 - 03:10:45 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:39 NZDT