SIGPIPE doesn't work in Cygwin?

  • Follow


Consider the following code (assume "sock" is the fd of a connected
socket and there is a client reading what we write):

while (1) {
    write(sock,str,strlen(str));
    sleep(1);
    }

Now, under Unix this works fine; if/when the client goes away, we get a
SIGPIPE and the process is killed.  This is good.

But, under Cygwin (current version - installed sometime in the last week
or two), it seems SIGPIPE isn't working.  The above code continues to
run even after the client is killed.

Note that changing the above to:

while (1) {
    if (write(sock,str,strlen(str)) != strlen(str)) _exit(0);
    sleep(1);
    }

does work, so that's my workaround.  Still, it would be nice if the
Unixy (simpler) way worked.

-- 
> No, I haven't, that's why I'm asking questions. If you won't help me,
> why don't you just go find your lost manhood elsewhere.

CLC in a nutshell.

0
Reply gazelle3 (1608) 5/18/2010 7:14:33 PM

On May 18, 12:14=A0pm, gaze...@shell.xmission.com (Kenny McCormack)
wrote:
> Consider the following code (assume "sock" is the fd of a connected
> socket and there is a client reading what we write):
>
> while (1) {
> =A0 =A0 write(sock,str,strlen(str));
> =A0 =A0 sleep(1);
> =A0 =A0 }
>
> Now, under Unix this works fine; if/when the client goes away, we get a
> SIGPIPE and the process is killed. =A0This is good.
>
> But, under Cygwin (current version - installed sometime in the last week
> or two), it seems SIGPIPE isn't working. =A0The above code continues to
> run even after the client is killed.

Windows sockets are not POSIX-compliant.
http://tangentsoft.net/wskfaq/articles/bsd-compatibility.html

DS
0
Reply David 5/19/2010 1:47:05 AM


1 Replies
69 Views

(page loaded in 0.054 seconds)

Similiar Articles:













7/17/2012 9:57:49 PM


Reply: