From: Kenny McCormack on
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.

From: David Schwartz on
On May 18, 12:14 pm, gaze...(a)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) {
>     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.

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

DS
 | 
Pages: 1
Prev: ptrace question
Next: Why linking?