检测 Solaris send() 调用中损坏的管道

发布于 2024-08-20 04:34:07 字数 159 浏览 3 评论 0原文

在solaris中如何检测send()调用中损坏的套接字?我不想使用信号。
我尝试了 SO_NOSIGPIPE 和 MSG_NOSIGNAL 但两者在 Solaris 中都不可用,并且我的程序因“损坏的管道”错误而被终止。

有什么办法可以检测到管道破损吗?

谢谢!

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 Solaris and my program is getting killed with "broken pipe" error.

Is there any way to detect broken pipe?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅浅 2024-08-27 04:34:07

您必须使用 sigaction() 来专门忽略 SIGPIPE 信号:

struct sigaction act;

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

...然后 send() 将返回 -1 并带有 < code>errno 设置为 EPIPE

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.

笑脸一如从前 2024-08-27 04:34:07

我想在 Solaris 中你只有有限的选择。 AFAIK,caf 建议的 sigaction 似乎是最好的解决方案。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文