delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/21/04:47:13

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 21 Apr 2004 10:46:59 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: write hangs on socket shut down for writing
Message-ID: <20040421084659.GD4092@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20040421011730 DOT GA2072 AT efn DOT org>
Mime-Version: 1.0
In-Reply-To: <20040421011730.GA2072@efn.org>
User-Agent: Mutt/1.4.2i

On Apr 20 18:17, Yitzchak Scott-Thoennes wrote:
> This seems to be the cause of perl's ext/Socket/t/socketpair.t test 14
> failing (which I've seen since at least 1.3.22).
> 
> $ cat pairsock.c
> #include <stdio.h>
> #include <sys/socket.h>
> #include <unistd.h>
> 
> int main (int argc, char **argv) {
>    int sockets[2] = {-1, -1};
>    int result;
>    ssize_t wrote;
> 
>    result = socketpair (AF_UNIX, SOCK_STREAM, PF_UNSPEC, sockets);
>    printf ("socketpair result: %d, left %d, right %d.\n", result, sockets[0], sockets[1]);
> 
>    result = shutdown (sockets[0], SHUT_WR);
>    printf ("shutdown result: %d.\n", result);
> 
>    printf ("writing 4 bytes to left socket.\n");
>    wrote = write (sockets[0], "nogo", 4);
>    printf ("write result: %ld.\n", (long)wrote);
>    return 0;
> }
> 
> $ gcc -Wall pairsock.c; ./a.exe
> socketpair result: 0, left 3, right 4.
> shutdown result: 0.
> writing 4 bytes to left socket.
> 
> ...and hangs there.
> 
> SUSv3 says:
> The write() function shall fail if:
> ...
> [EPIPE] 
> A write was attempted on a socket that is shut down for writing, or is
> no longer connected. In the latter case, if the socket is of type
> SOCK_STREAM, the SIGPIPE signal is generated to the calling process.

Did you try it with a recent Cygwin version?  I used your above test
application and I'm getting a EPIPE (resp. a SIGPIPE) as expected.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Co-Project Leader          mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019