Re: Debugging SIGPIPE ?
Re: Debugging SIGPIPE ?
- Subject: Re: Debugging SIGPIPE ?
- From: Matt DeFoor <email@hidden>
- Date: Wed, 7 Jul 2010 12:59:41 -0400
Alex,
Is the app performing socket IO? If so, simply setting up a handler
for SIGPIPE is sometimes not good enough. You may have to test if you
can write to the socket:
// Ignore SIGPIPE so that program does not abnormally exit
signal(SIGPIPE, SIG_IGN);
...
while (isConnected) {
tv.tv_sec = 1;
tv.tv_usec = 0;
FD_ZERO(&writefds);
FD_SET(sockfd, &writefds);
rval = select(sockfd + 1, (fd_set*)0, &writefds, (fd_set*)0, &tv);
if (rval < 0)
continue;
if (FD_ISSET(sockfd, &writefds)) {
FD_CLR(sockfd, &writefds);
if (write(sockfd, buff, strlen(buff)) < 0) {
switch (errno) {
case EBADF :
case EPIPE :
case EFBIG :
case EFAULT :
case EINVAL :
case EIO :
case EWOULDBLOCK :
case EINTR :
isConnected = false;
break;
}
}
else {
isConnected = true;
break;
}
}
else {
isConnected = false;
break;
}
}
...
That's just typed in and is a simple mechanism for testing if you can
write to a socket...
-Matt
On Wed, Jul 7, 2010 at 12:17 PM, Alexander v. Below <email@hidden> wrote:
> Hello,
>
> one of our more complex (Mac OS X, Cocoa) projects will occasionally crash with a SIGPIPE interruption. We have set up a handler using signal(3), but that is not even called.
>
> Are there any hints how to get to the root of this problem? Or am I maybe seing an artifact of the debugger, and really something else has gone wrong? (If so, how would I know?)
>
> Thanks
>
> Alex
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden