Re: Coalescing pipe allocation

From: Peter Edwards <peter.edwards_at_openet-telecom.com>
Date: Tue, 03 Feb 2004 16:54:18 +0000
Dag-Erling Smørgrav wrote:

>Peter Edwards <peter.edwards_at_openet-telecom.com> writes:
>  
>
>>How would one "shut down" one direction of the pipe and still maintain
>>the other? I don't know how I can signal my intention not to read or
>>write to the end I leave open...
>>    
>>
>
>man 2 shutdown
>  
>
Shutdown requires a socket, and won't play with pipes:

$ cat t.c
#include <sys/types.h>
#include <sys/socket.h>
#include <err.h>
#include <unistd.h>
int
main()
{
    int p[2];
    if (pipe(p) == -1)
        err(-1, "pipe");
    if (shutdown(p[0], SHUT_RD) == -1)
        err(-1, "shutdown");
    return 0;
}
$ cc -o t ./t.c
$ ./t
./t: shutdown: Socket operation on non-socket
$

>  
>
>>Is this portability issue so ridiculously out of date that the comment
>>in the pipe(2) manpage should be removed, or at least toned down?
>>    
>>
>
>No, POSIX only guarantees the traditional behaviour.  Bi-directional
>pipes are a non-portable BSDism.
>
>  
>
>>                                                                  It
>>seems silly to incur the costs of implementation you've mentioned and
>>then recommend that the feature not be used.
>>    
>>
>
>It can still be useful for programs in the base system, which do not
>need to be unconditionally portable to non-BSD systems.
>  
>
Fair 'nuff.
Received on Tue Feb 03 2004 - 07:54:29 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:41 UTC