开发者

Detecting broken pipe in Solaris send() call

In solaris how to detect broken socket in send() call? i dont want to use signal.

i tried SO_NOSIGPIPE and MSG_NOSIGNAL but both are not available in S开发者_JAVA百科olaris and my program is getting killed with "broken pipe" error.

Is there any way to detect broken pipe?

Thanks!


You'll have to use sigaction() to specifically ignore the SIGPIPE signal:

struct sigaction act;

act.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &act, NULL);

...then send() will return -1 with errno set to EPIPE.


I guess in Solaris you have only limited options. AFAIK, sigaction suggested by caf appears to be the best solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜