信号处理,中断处理方面的问题 [英] Issue with signal handling, interrupt handling

查看:116
本文介绍了信号处理,中断处理方面的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当进程正在执行阻塞系统调用(例如读或写)时,信号已到达. 系统调用是否以错误EINTR终止? 处理系统调用后,系统调用是否重新启动?

While the process is executing a blocking system call, say read or write, signal has arrived. Does the system call is terminated with the error EINTR? Does the system call is restarted after handling the system call?

假设系统调用因错误EINTR而终止,内核将在重新进入用户空间之前处理该信号.

Suppose, system call is terminated with the error EINTR, Kernel handles the signal before returing to user space.

信号句柄是否在用户模式/内核模式下执行? 如果它处于用户模式,那么在系统调用(读/写)后信号到达的过程中是否将返回到指令,或者在处理信号并从ret_from_syscall返回用户后再次进入内核模式.如何在信号到达期间的系统调用旁的指令处恢复执行?

Does the signal handle is executed in user mode/kernel mode? If its in user mode, does there'll be return to the instruction after the system call(read/write) during which signal arrived or again it goes to kernel mode after handling the signal and returns to the user from ret_from_syscall. How the execution is resumed at the instruction next to the system call during which signal arrived?

是否有可能通过在活动中传递SA_RESTART标志来重新启动系统?

Is it possible to restart the system by passing SA_RESTART flag in sigaction?

推荐答案

信号以用户模式执行,但使用其他用户 context ,然后返回内核,它通过ret_from_syscall返回到user_mode. 在SA_RESTART中安装了信号处理程序时,系统调用的行为取决于系统调用.

Signal is executed in user mode, but with a different user context, then return to kernel, which return to user_mode with ret_from_syscall. The behaviour of system call when signal handler are installed with SA_RESTART depends on the system call.

如果未使用SA_RESTART标志,则不会重新启动系统调用.

If the SA_RESTART flag is not used, system call is not restarted.

这篇关于信号处理,中断处理方面的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆