一个信号处理输出问题。。

897阅读 0评论2010-05-09 maxxfire
分类:LINUX

 
static g = 0;
void ttt(int no, siginfo_t *info, void * ctx)
{
        printf("%d\n", g++);
        int i;
        for(i=0; i<100000000; i++)
                ;
}
int main()
{
        struct sigaction siga = {0};

        siga.sa_sigaction = ttt;
        siga.sa_flags |= SA_SIGINFO;
        sigaction(SIGINT, &siga, NULL);

        while(1)
        {
                sleep(1);
        }
}


运行后,在终端不断的Ctrl+C,运行结果如下:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
23
24
25
...


22竟然没有打印。。


加上我的测试环境:
Linux 2.6.18-164.el5 #1 SMP x86_64 GNU/Linux
SecureCRT(Version 6.1.2 (build 409)) 通过SSH2远程TCP连接
上一篇:在短时间内掌握VIM命令精髓。。
下一篇:[转]Mounting a hard disk image including partitions