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]$ 

 

你可能感兴趣的:(Signal)