SIGPIPE and EPIPE
SIGPIPE and EPIPE
- Subject: SIGPIPE and EPIPE
- From: Chilton Webb <email@hidden>
- Date: Sun, 17 Mar 2002 13:27:20 -0600
I am trying to debug a c app in Project Builder that could potentially
receive a SIGPIPE during a call to write. The problem is that if I
ignore it, I never get a chance to check the errno variable, it just
hangs on write.
It's been suggested on the Project Builder list that I need to allow the
SIGPIPE signal to pass through, as the debugger will capture it
regardless of whether my app does or not. To do that, I use this command:
handle SIGPIPE nostop
Now, in my code (main, actually), I'm doing this...
signal(SIGPIPE,SIG_IGN);
And later, here's my write function...
ssize_t writen(int fd, const void *vptr, size_t n)
{
size_t nleft;
ssize_t nwritten;
const char *ptr;
ptr = vptr;
nleft = n+1;
while (nleft > 0) {
nwritten = write(fd, ptr, nleft);
if (nwritten < 0) {
if (errno == EPIPE) return -2;
else return -1;
}
nleft -= nwritten;
ptr += nwritten;
}
return(n);
}
Can anyone tell me why it hangs on write if I pass the SIGPIPE error
through? By 'hang', I mean that the debugger becomes unresponsive to
anything but killing the app (via the stopsign button). I can't pause
it, I can't step it, and new clients cannot connect to it (of course).
Thank you,
-Chilton
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.