Determine which signal caused EINTR?

这一生的挚爱 提交于 2019-12-22 08:34:19

问题


I am running an epoll loop and sometimes my call to epoll_wait returns -1 with errno set to EINTR. Sometimes, I want this to end the epoll loop, like in the case of SIGTERM or SIGINT. But I have this code compiled with the -pg flag, so periodic SIGPROF (27) signals are raised that stop my loop.

So... is it possible to switch on the signum so that I can determine when to exit vs. continue? I would like to avoid anything that employs the use of a global to keep track of the most recent signal fired.


回答1:


Add signal handlers on SIGTERM and SIGINT. Inside those handlers you set a variable that you check in your main epoll loop



来源:https://stackoverflow.com/questions/19910099/determine-which-signal-caused-eintr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!