Re: Testing anti spam software
Hello,
On Jul 24, 9:30 am, Ron Johnson <ron.l.john...@cox.net> wrote:
> Write a small do-nothing program that lets me test the USR & HUP
> signals. Make it simple enough that a poor C programmer can
> understand it. I'll compile and run it, then send you the results.
Thank you. Here is the basic form I now use:
#include
<stdio.h>
#include
<stdlib.h>
#include
<signal.h>
void SigHandler(int
sig);
int main(int argc, char
*argv[])
{
signal(SIGHUP,SigHandler);
signal(SIGUSR1,SigHandler);
signal(SIGUSR2,SigHandler);
while(1);
}
void SigHandler(int
sig)
{
switch(sig)
{
case SIGHUP: printf("HUP\n");
break;
case SIGUSR1: printf("USR1\n");
break;
case SIGUSR2: printf("USR2\n"); exit(0);
break;
}
}
It can be compiled with:
gcc -o sigtest sigtest.c
I know sigaction is now the perferred way to do signals, but I kept
getting unpredictable results.
SIGUSR2 will exit the program. I believe this will work flawlessly.
---
DynaStop: Stopping spam one dynamic IP address at a time.
http://tanaya.net/DynaStop/
Reply to: