C语言signal处理的小例子

时间:2021-08-01 07:16:38
[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(); return ; }
[pgsql@localhost tst]$