[comp.unix.internals] How to distinguish between STREAMS and non-STREAMSD

ccdn@levels.sait.edu.au (01/24/91)

josef@nixpbe.nixdorf.de (josef Moellers) writes:
>Does anybody now of a bulletproof and FAST method to distinguish between
>a STREAMS fd and a non-STREAMS fd?
>I cannot use calls to getmsg/putmsg, as I am not allowed to change the
>state of the STREAM.

This is a guess, and right now I don't have the facilities to test it out.

I assume that getmsg/putmsg will return errno = E_INVALID if you pass it a
STREAMS fd?  So why not assume that getmsg/putmsg will work, and test the
return result; if you get errno = E_INVALID then try your STREAMS code; if
that fails, and if you've got nothing else to try, then you're stuck.  (But
then, in that case you always would have been stuck, wouldn't you?)

David Newall, who no longer works       Phone:  +61 8 344 2008
for SA Institute of Technology          E-mail: ccdn@lux.sait.edu.au
"Life is uncertain:  Eat dessert first"  *Check the return address!*

khh@root.co.uk (Keith Holder) (01/25/91)

>josef@nixpbe.nixdorf.de (josef Moellers) writes:
>>Does anybody now of a bulletproof and FAST method to distinguish between
>>a STREAMS fd and a non-STREAMS fd?
>>I cannot use calls to getmsg/putmsg, as I am not allowed to change the
>>state of the STREAM.

In System V Release 4, there is a library function called isastream(3C), which 
takes a file descriptor as an argument. It returns 1 if fildes represents a
STREAMS file, 0 if not. It behaves very much like  isatty().
	I don't know whether this function was available in previous releases.
-- 
--
Keith Holder, Systems Software Consultant, UniSoft Ltd.
<khh@root.co.uk>	G1ITH	Fax:	(071) 729 3273
Phone:	+44 71 729 3773 

stevea@i88.isc.com (Steve Alexander) (01/28/91)

In article <2585@root44.co.uk> khh@root.co.uk (Keith Holder) writes:
>In System V Release 4, there is a library function called isastream(3C), which 
>I don't know whether this function was available in previous releases.

Isastream does an I_CANPUT ioctl on the descriptor.  This ioctl did not
exist under pre-SVR4 releases of System V, and I don't believe that
isastream did either...

--
Steve Alexander, Software Technologies Group    | stevea@i88.isc.com
INTERACTIVE Systems Corporation, Naperville, IL | ...!{sun,ico}!laidbak!stevea

rembo@unisoft.UUCP (Tony Rems) (02/02/91)

In article <2585@root44.co.uk> khh@root.co.uk (Keith Holder) writes:
>
>>josef@nixpbe.nixdorf.de (josef Moellers) writes:
>>>Does anybody now of a bulletproof and FAST method to distinguish between
>>>a STREAMS fd and a non-STREAMS fd?
>>>I cannot use calls to getmsg/putmsg, as I am not allowed to change the
>>>state of the STREAM.
>
>In System V Release 4, there is a library function called isastream(3C), which 
>takes a file descriptor as an argument. It returns 1 if fildes represents a
>STREAMS file, 0 if not. It behaves very much like  isatty().
>	I don't know whether this function was available in previous releases.

The isastream(3C) library routine just does and ioctl(2) with the I_CANPUT
request.  So, if the pre-SVR4 system you have doesn't have the I_CANPUT
(and I don't see it in the SVR3.2 STREAMS programmer's guide), you
probably don't have this and can't simulate it in the same simple way :).

Just my two bits.

-Tony