diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-10-31 16:07:28 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-10-31 16:07:28 +0000 |
commit | 74e2d2844b6fd490ef77ffadb33dd73ecc368d0c (patch) | |
tree | f2aada53adf32c0ba40ad3bb6f4d503528d81cb4 /fetchmail.c | |
parent | 4a8242b06d276dd1c477c9cfe1bf494c3200c4e9 (diff) | |
download | fetchmail-74e2d2844b6fd490ef77ffadb33dd73ecc368d0c.tar.gz fetchmail-74e2d2844b6fd490ef77ffadb33dd73ecc368d0c.tar.bz2 fetchmail-74e2d2844b6fd490ef77ffadb33dd73ecc368d0c.zip |
Better signal handling.
svn path=/trunk/; revision=459
Diffstat (limited to 'fetchmail.c')
-rw-r--r-- | fetchmail.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fetchmail.c b/fetchmail.c index de5397b3..7d54fd7d 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -66,8 +66,9 @@ char *user; /* the name of the invoking user */ static void termhook(); static char *lockfile; static int popstatus; +static int lastsig; -RETSIGTYPE donothing(sig) int sig; {signal(sig, donothing);} +RETSIGTYPE donothing(sig) int sig; {signal(sig, donothing); lastsig = sig;} int main (argc,argv) int argc; @@ -357,10 +358,10 @@ char **argv; } /* - * We can't use sleep(3) here, the alarm(2) call used to - * implement server nonresponse timeout collides with it. + * We can't use sleep(3) here because we need an alarm(3) + * equivalent in order to implement server nonresponse timeout. * We'll just assume setitimer(2) is available since fetchmail - * has to have the socket layer to work at all. + * has to have a BSDoid socket layer to work at all. */ { struct itimerval ntimeout; @@ -369,10 +370,11 @@ char **argv; ntimeout.it_value.tv_sec = poll_interval; ntimeout.it_value.tv_usec = 0; - if (setitimer(ITIMER_REAL,&ntimeout,NULL)==-1 && errno==EINTR) - (void) fputs("fetchmail: awakened by SIGHUP\n", stderr); + setitimer(ITIMER_REAL,&ntimeout,NULL); signal(SIGALRM, donothing); pause(); + if (lastsig == SIGHUP) + (void) fputs("fetchmail: awakened by SIGHUP\n", stderr); } if (outlevel == O_VERBOSE) |