How are signals handled in Unix?

萝らか妹 提交于 2019-12-13 09:54:30

问题


My question is that how are signals handled in Unix. Are they handled by making new thread or there is something else? Also what is the flow of execution of programme when a signal comes?

What I mean by flow of execution is that, let's say I am in middle of a function X and call to another function Y comes. So the compiler goes pauses the execution of function X and goes to function Y. After finishing the function Y the compiler again continues the execution of programme X from where it was paused. Similarly I would like to know how programme executes when a signal comes.

I am using settimer in my programme to execute a function. But when I lower the interval value the function is called again and previous execution is cancelled, though I am not sure about it. The code is too messy and long so I have not posted it here.

Thanks for looking into it..!


回答1:


The operating system stops running the thread receiving the signal and runs the signal handler. When it returns the original thread restarts where it was.

If the signal handler is already running when another signal comes in, the action is configurable in the sigaction call.



来源:https://stackoverflow.com/questions/34454737/how-are-signals-handled-in-unix

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