常见的linux对read,write等系统调用被信号中断会自动设置重启,通过sigaction设置不自动重启。


typedef void (*sighandler_t)(int);

sighandler_t signal_intr(int signo,sighandler_t func)
{
 struct sigaction act,oact;
 act.sa_handler = func;
 sigemptyset(&act.sa_mask);
 act.sa_flags = 0;
#ifdef SA_INTERRUPT
 act.sa_flags |= SA_INTERRUPT;
#endif
 if(sigaction(signo,&act,&oact) < 0)
  return (SIG_ERR);
 return (oact.sa_handler);
}
转载请注明来源:Leoncom-《不重启被信号中断的系统调用》
Trackback

6 comments untill now

  1. wangzheng @ 2009-06-17 20:06

    linux大牛~~强哥加油~~

  2. 您是挑战我的智商

  3. 你好,在你之前的搜狐博客看了一篇文章,想问下你。http://danieltale.blog.sohu.com/47239904.html?act=1245827127765#comment

  4. 可以给我邮箱回复。

  5. I am regular reader, how are you everybody? This piece of writing posted at this website is truly pleasant.

  6. perfect new home gift, was very well recieved. Very happy customer.

Add your comment now