本文介绍了epoll_wait由于EINTR而失败,该如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于EINTR,我的epoll_wait失败.我的gdb跟踪显示了这一点:

My epoll_wait fails due to EINTR. My gdb trace shows this:

enter code here
221     in ../nptl/sysdeps/pthread/createthread.c
(gdb)
224     in ../nptl/sysdeps/pthread/createthread.c
(gdb)
 [New Thread 0x40988490 (LWP 3589)]

227     in ../nptl/sysdeps/pthread/createthread.c
(gdb)
epoll_wait error in start timer: Measurement will befor entire duration of execution
epoll_wait: Interrupted system call
[Thread 0x40988490 (LWP 3589) exited]

我在stderr中打印了此字符串启动计时器中的epoll_wait错误:将在整个执行过程中进行测量".

This string "epoll_wait error in start timer: Measurement will befor entire duration of execution" is printed by me in stderr.

我不知道如何解决此EINTR,以便epoll_wait可以工作.知道GDB跟踪如何生成此EINTR吗?

I am not able to make out, how to remedy this EINTR so that epoll_wait can work. Any idea how this EINTR is generated by GDB trace?

推荐答案

在任何Unix或Linux上,某些信号处理程序都会中断epoll_wait()select()和类似的系统调用.这是设计使您可以中断这些系统调用.

Certain signal handler will interrupt epoll_wait(), select() and similar system calls on any Unix or Linux. This is by design so you can interrupt these system calls.

您不能直接对其进行补救.典型的解决方案是显式检查EINTR的errno并再次执行epoll_wait():

You cannot directly remedy it. The typical solution is to explicitly check the errno for EINTR and to execute epoll_wait() again:

int nr;
do {
    nr = epoll_wait(epfd, events, maxevents, timeout);
} while (nr < 0 && errno == EINTR);

另请参阅: gdb错误:无法执行epoll_wait:(4)中断系统调用

这篇关于epoll_wait由于EINTR而失败,该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 14:15