C语言signal处理的小例子

[pgsql@localhost tst]$ cat sig01.c
#include <stdio.h>
#include <signal.h>

static void
trapsigterm(int signum)
{
        fprintf(stderr,"+++++++++++Got SIGTERM with %d\n",signum);
}

static void
trapsigquit(int signum)

{
        fprintf(stderr,"+++++++++++Got SIGQUIT with %d\n",signum);
}

int main()
{

   signal(SIGTERM,trapsigterm);
   signal(SIGQUIT,trapsigquit);
   
   sleep(10);

   return 0;

}
[pgsql@localhost tst]$ 

 

posted @ 2013-07-07 19:48  健哥的数据花园  阅读(1767)  评论(0编辑  收藏  举报