我在我的应用中调用syscall sigsuspend (API sys_sigsuspend ),错误号为 < em> -ERESTARTNOHAND 。但是我在errno.h中得到了以下信息,看来我 不应 在我的应用程序中得到errno。
/*
8 * These should never be seen by user programs. To return one of ERESTART*
9 * codes, signal_pending() MUST be set. Note that ptrace can observe these
10 * at syscall exit tracing, but they will never be left for the debugged user
11 * process to see.
12 */
13 #define ERESTARTSYS 512
14 #define ERESTARTNOINTR 513
15 #define ERESTARTNOHAND 514 /* ***restart if no handler..*** */
然后我检查内核代码,ERESTARTNOHAND将被转换为EINTR,似乎永远不会返回用户空间。
void do_signal(struct pt_regs *regs)
{
struct ksignal ksig;
if (get_signal(&ksig)) {
/* Whee! Actually deliver the signal. */
handle_signal(&ksig, regs);
return;
}
/* Did we come from a system call? */
if (syscall_get_nr(current, regs) >= 0) {
/* Restart the system call - no handlers present */
switch (syscall_get_error(current, regs)) {
case -ERESTARTNOHAND:
case -ERESTARTSYS:
case -ERESTARTNOINTR:
regs->ax = regs->orig_ax;
regs->ip -= 2;
break;
case -ERESTART_RESTARTBLOCK:
regs->ax = get_nr_restart_syscall(regs);
regs->ip -= 2;
break;
}
}
/*
* If there's no signal to deliver, we just put the saved sigmask
* back.
*/
restore_saved_sigmask();
}
handle_signal(struct ksignal *ksig, struct pt_regs *regs)
{
bool stepping, failed;
struct fpu *fpu = ¤t->thread.fpu;
if (v8086_mode(regs))
save_v86_state((struct kernel_vm86_regs *) regs, VM86_SIGNAL);
/* Are we from a system call? */
if (syscall_get_nr(current, regs) >= 0) {
/* If so, check system call restarting.. */
switch (syscall_get_error(current, regs)) {
case -ERESTART_RESTARTBLOCK:
case -ERESTARTNOHAND:
regs->ax = -EINTR;
break;
......
}
我的问题是 :