1
Ignore SIGPIPE signal
Imported from the Apple Support Forums via the Wayback Machine 🔗
My application trying to connect to server and receive signal SIGPIPE. How can i catch this signal?
I found two solution for this problem, but either doesn't work.
First solution is:
void SigPipeHandler(int s);
int main(int argc, char *argv[]) {
signal(SIGPIPE, SigPipeHandler);
...
}
void SigPipeHandler(int s){
NSLog(@"SigPipeHandler");
}
In second solution I'm trying to ignore SIGPIPE signal as follow:
int main(int argc, char *argv[]) {
struct sigaction mySigAction;
mySigAction.sa_handler = SIG_IGN;
sigemptyset(&mySigAction.sa_mask);
sigaction(SIGPIPE, &mySigAction, NULL);
...
}
but signal isn't ignored. I'm also trying to handle signal to set handler:
int main(int argc, char *argv[]){
struct sigaction mySigAction;
mySigAction.sa_sigaction = SignalHandler;
mySigAction.sa_flags = SA_SIGINFO;
sigemptyset(&mySigAction.sa_mask);
sigaction(SIGPIPE, &mySigAction, NULL);
...
}
void SignalHandler(int sig, siginfo_t *info, void *context){
NSLog(@"in SignalHandler");
}
but it doesn't work too.
And on the whole, why can I handle any signal?
Message was edited by: iruirc
Message was edited by: iruirc
1 reply
Sign in or join Beachball Help to reply.
- 0