|
57 | 57 | # endif |
58 | 58 | #endif |
59 | 59 |
|
| 60 | +static volatile int pause_now = 0; |
| 61 | +static volatile int running = 1; |
60 | 62 | static int verbose = 0; |
61 | | -static int pause_now = 0; |
62 | 63 | static int dry_run = 0; |
63 | 64 | static int poll_sysfs = 0; |
64 | 65 | static int hardware_logic = 0; |
65 | 66 | static int force_software_logic = 0; |
66 | 67 | static int sampling_rate = 0; |
67 | | -static int running = 1; |
68 | 68 | static int background = 0; |
69 | 69 | static int dosyslog = 0; |
70 | 70 | static int forcerotational = 0; |
@@ -367,17 +367,19 @@ double get_utime (void) |
367 | 367 | */ |
368 | 368 | void SIGUSR1_handler (int sig) |
369 | 369 | { |
370 | | - signal(SIGUSR1, SIGUSR1_handler); |
371 | 370 | pause_now = 1; |
| 371 | + if (verbose) |
| 372 | + printlog(stdout, "SIGUSR1 called, pause_now is %d", pause_now); |
372 | 373 | } |
373 | 374 |
|
374 | 375 | /* |
375 | 376 | * SIGTERM_handler - Handler for SIGTERM, deletes the pidfile and exits. |
376 | 377 | */ |
377 | 378 | void SIGTERM_handler (int sig) |
378 | 379 | { |
379 | | - signal(SIGTERM, SIGTERM_handler); |
380 | 380 | running = 0; |
| 381 | + if (verbose) |
| 382 | + printlog(stdout, "SIGTERM called, running is %d", running); |
381 | 383 | } |
382 | 384 |
|
383 | 385 | /* |
@@ -1206,9 +1208,17 @@ int main (int argc, char** argv) |
1206 | 1208 | if (verbose) |
1207 | 1209 | printf("sampling_rate: %d\n", sampling_rate); |
1208 | 1210 |
|
1209 | | - signal(SIGUSR1, SIGUSR1_handler); |
| 1211 | + struct sigaction sa; |
| 1212 | + sigemptyset (&sa.sa_mask); |
| 1213 | + sa.sa_flags = 0; |
| 1214 | + |
| 1215 | + /* Register the handler for SIGUSR1. */ |
| 1216 | + sa.sa_handler = SIGUSR1_handler; |
| 1217 | + sigaction (SIGUSR1, &sa, NULL); |
1210 | 1218 |
|
1211 | | - signal(SIGTERM, SIGTERM_handler); |
| 1219 | + /* Register the handler for SIGTERM. */ |
| 1220 | + sa.sa_handler = SIGTERM_handler; |
| 1221 | + sigaction (SIGTERM, &sa, NULL); |
1212 | 1222 |
|
1213 | 1223 | while (running) { |
1214 | 1224 | if (!hardware_logic) { /* The decision is made by the software */ |
|
0 commit comments