ChinaUnix.net
相关文章推荐:

sigsuspend

apue书上说的 sigset_t new,old,mask; sigemptyset(&new); sigaddset(&new ,SIGINT); sigprocmask(SIG_BLOCK,&new,&old); 临界区.........//阻塞收到SIGINT信号 (1) sigprocmask(SIG_SETMASK,&old,NULL); ....书上说在这一区间,因为要接收前面(1)处的信号,所以再发生SIGINT信号会丢失。信号不是可以排队的么,为什么书上说会丢失? pause();//pause是不是所有的信号都可以打断它? 换成下面这样就不会 --------...

by dxbh - C/C++ - 2009-09-16 18:03:12 阅读(4432) 回复(10)

相关讨论

Unix提供了等待信号的系统调用,sigsuspend就是其中一个,在CU( [color="#4a664d"]www.chinaunix.net )上曾经讨论过一个关于该系统调用的问题,这里也做一下解疑。 CU网友讨论的问题的核心就是到底sigsuspend先返回还是signal handler先返回。这个问题Stevens在《Unix环境高级编程》一书中是如是回答的“If a signal is caught and if the signal handler returns, then sigsuspend returns and the signal mask of the pro...

by xueyan - Linux文档专区 - 2006-07-17 10:33:16 阅读(479) 回复(0)

Unix提供了等待信号的系统调用,sigsuspend就是其中一个,在CU( www.chinaunix.net )上曾经讨论过一个关于该系统调用的问题,这里也做一下解疑。 CU网友讨论的问题的核心就是到底sigsuspend先返回还是signal handler先返回。这个问题Stevens在《Unix环境高级编程》一书中是如是回答的“If a signal is caught and if the signal handler returns, then sigsuspend returns and the signal mask of the process is set to its valu...

by j4ckl1u - Linux文档专区 - 2006-07-17 10:30:14 阅读(518) 回复(0)

都说sigsuspend是原子操作,并且ULK3上也有类似的描述 "the sigsuspend() system call does not allow signals to be sent after unblocking and before the schedule() invocation, because other processes cannot grab the CPU during that time interval" 但是从代码上看spin_unlock_irq之后到schedule()之前完全可以被其他CPU抢占。这个原子操作怎么实现呢? sys_sigsuspend(int history0, int history1, old_sigset_t mas...

by littlenewer - 内核源码 - 2012-03-29 15:25:20 阅读(1249) 回复(0)

看了《unix 环境高级编程》上面关于pause()和sigsuspend()函数,但是不懂他们究竟有些什么区别,在什么时候可以相互替换,什么时候又不可以呢?

by sshh2010 - Linux环境编程 - 2014-05-31 12:34:17 阅读(3788) 回复(3)

手册: #include int sigsuspend(const sigset_t *sigmask);The sigsuspend() function shall replace the current signal mask of the calling thread with the set of signals pointed to by sigmask and then suspend the thread until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. This shall not cause any other signals t...

by dengjin - Linux文档专区 - 2010-01-22 20:03:48 阅读(1011) 回复(0)

一开始没看明白APUE里的例子,后来google了下搜索到了这篇文章 http://bigwhite.blogbus.com/logs/1453143.html 它讲: [code] 如果按照sig_handler先返回,那么SIGINT是不该被打印出来的,因为那时屏蔽字还没有恢复,所有信号都是不阻塞的。那么是Stevens说错了么?当然没有,只是Stevens没有说请在sigsuspend的原子操作中到底做了什么? sigsuspend的整个原子操作过程为: (1) 设置新的mask阻塞当前进程; (2) 收到信号,恢复原先...

by bsdc - C/C++ - 2009-08-09 02:07:02 阅读(4036) 回复(13)

手册: #include int sigsuspend(const sigset_t *sigmask); The sigsuspend() function shall replace the current signal mask of the calling thread with the set of signals pointed to by sigmask and then suspend the thread until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. This shall not cause any other signals that ...

by wqfhenanxc - Linux文档专区 - 2009-04-12 17:21:26 阅读(593) 回复(0)

hi,这段程序主要用来打印各个不同阶段被block的signal掩码。。但是对结果不明白。。 程序有点长,不过逻辑很简单。。 #include #include #include static void sig_int(int); void err_sys(const char *s) { printf(s); exit(0); } void pr_mask(const char *str) { sigset_t sigset; int errno_s...

by maxxfire - C/C++ - 2012-05-24 02:17:26 阅读(2885) 回复(6)

下面是APUE2中程序10_16,问题见程序中描述: [code] #include #include #include volatile sig_atomic_t quitflag; static void sig_handler(int signo); int main(int argc, char** argv) { struct sigaction act1, act2; sigset_t newmask, oldmask, zeromask; act1.sa_flags = 0; act1....

by xiaozhu2007 - C/C++ - 2010-11-26 23:16:23 阅读(3782) 回复(10)

我想问一下sigsuspend()什么时候能够返回呢?是不是接收到信号才能返回呢?

by zhn636 - Linux环境编程 - 2007-08-30 19:29:11 阅读(1647) 回复(5)