git-svn: trunk@333
Thomas Lamy authored on 2004/02/24 08:27:32... | ... |
@@ -54,6 +54,7 @@ static void daemon_sighandler(int sig) { |
54 | 54 |
case SIGALRM: |
55 | 55 |
case SIGUSR1: |
56 | 56 |
action = "wake up"; |
57 |
+ terminate = -1; |
|
57 | 58 |
break; |
58 | 59 |
|
59 | 60 |
case SIGHUP: |
... | ... |
@@ -203,6 +204,7 @@ int freshclam(struct optstruct *opt) |
203 | 203 |
|
204 | 204 |
if(optc(opt, 'd')) { |
205 | 205 |
int bigsleep, checks; |
206 |
+ time_t now, wakeup; |
|
206 | 207 |
|
207 | 208 |
memset(&sigact, 0, sizeof(struct sigaction)); |
208 | 209 |
sigact.sa_handler = daemon_sighandler; |
... | ... |
@@ -251,8 +253,16 @@ int freshclam(struct optstruct *opt) |
251 | 251 |
logg("\n--------------------------------------\n"); |
252 | 252 |
sigaction(SIGALRM, &sigact, &oldact); |
253 | 253 |
sigaction(SIGUSR1, &sigact, &oldact); |
254 |
+ time(&wakeup); |
|
255 |
+ wakeup += bigsleep; |
|
254 | 256 |
alarm(bigsleep); |
255 |
- pause(); |
|
257 |
+ do { |
|
258 |
+ pause(); |
|
259 |
+ time(&now); |
|
260 |
+ } while (!terminate && now < wakeup); |
|
261 |
+ if (terminate == -1) { |
|
262 |
+ terminate = 0; |
|
263 |
+ } |
|
256 | 264 |
sigaction(SIGALRM, &oldact, NULL); |
257 | 265 |
sigaction(SIGUSR1, &oldact, NULL); |
258 | 266 |
} |