Unix Programming - How to find the type of pipe implementation

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2004 > How to find the type of pipe implementation





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to find the type of pipe implementation
Madhusudan Singh

2004-04-21, 6:36 pm

Linux implements half-duplex pipes, while Sun (or so I have read) provides
full duplex pipes. Is there an elegant way of finding out the kind of
implementation ?

Under Linux, popen() opens a uni-directional pipe to another process. Is
this still true under Sun ?
DeMarcus

2004-04-21, 7:36 pm



Madhusudan Singh wrote:
> Linux implements half-duplex pipes, while Sun (or so I have read) provides
> full duplex pipes. Is there an elegant way of finding out the kind of
> implementation ?
>


I'm not sure what exactly you're gonna do, but I have a little tips. As
I remember it (I may be wrong) you can emulate full-duplex pipes with
sockets. I'm not sure if that fixed your problem though.

> Under Linux, popen() opens a uni-directional pipe to another process. Is
> this still true under Sun ?


Rich Teer

2004-04-21, 10:35 pm

On Wed, 21 Apr 2004, Madhusudan Singh wrote:

> Linux implements half-duplex pipes, while Sun (or so I have read) provides


Yes, that's correct.

> full duplex pipes. Is there an elegant way of finding out the kind of
> implementation ?


Call isastream() with the one of the pipe's fd's. If it's a STREAMS
device, odds are its a full-duplex pipe.

--
Rich Teer, SCNA, SCSA

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net
Michael Kerrisk

2004-04-22, 3:36 am

On Thu, 22 Apr 2004 02:28:11 GMT, Rich Teer <rich.teer@rite-group.com>
wrote:

>On Wed, 21 Apr 2004, Madhusudan Singh wrote:
>
>
>Yes, that's correct.
>
>
>Call isastream() with the one of the pipe's fd's. If it's a STREAMS
>device, odds are its a full-duplex pipe.


Yes, but that's not sufficient. On the BSDs, pipes are implemented
using socket, and are bidrirectional.

Cheers,

Michael
Michael Kerrisk

2004-04-22, 3:36 am

On Wed, 21 Apr 2004 18:41:04 -0400, Madhusudan Singh
<spammers-go-here@yahoo.com> wrote:

>Linux implements half-duplex pipes, while Sun (or so I have read) provides
>full duplex pipes.


This is correct.

>Is there an elegant way of finding out the kind of
>implementation ?


Why do you need to know? Making use of the non-standard,
bidirectional feature that is available in some pipes implementations
is non-portable.

There is no "elegant" way of determining this, as far as I know. (See
also my other post in this thread.) The simplest way would be to
write a small program that creates a pipe and tries to write on both
ends.

>Under Linux, popen() opens a uni-directional pipe to another process. Is
>this still true under Sun ?


This is the nature of popen(), and has nothing to do with the
underlying pipes implementation. The Solaris(8) popen man page says:

The command argument consists of a shell command line. The
mode argument is an I/O mode, either r for reading or w for
writing.

In other words, it's EITHER read OR write.

Cheers,

Michael
Arto Huusko

2004-04-22, 8:38 am

Michael Kerrisk wrote:
> On Thu, 22 Apr 2004 02:28:11 GMT, Rich Teer <rich.teer@rite-group.com>
> wrote:
>
>
> Yes, but that's not sufficient. On the BSDs, pipes are implemented
> using socket, and are bidrirectional.


And newer versions of the BSDs (at least Net and Free) again don't
use sockets. But I can't remember whether the new pipe implementation
is bidirectional (IIRC, it is not).

Wouldn't it be best to not guess about the pipe implementation, and
go directly with the sockets. That would be more portable in any
case.

--
Arto Huusko
Michael Kerrisk

2004-04-22, 10:44 am

On Thu, 22 Apr 2004 15:03:42 +0300, Arto Huusko
<arto.huusko@novogroup.com> wrote:

>Michael Kerrisk wrote:
>
>And newer versions of the BSDs (at least Net and Free) again don't
>use sockets. But I can't remember whether the new pipe implementation
>is bidirectional (IIRC, it is not).


I haven't checked the BSD code, but can you say more about this? I
just now did a quick test on FreeBSD 5.1, and pipes seem to be
bidirectional...

Cheers,

Michael
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com