...
| Code Block | ||
|---|---|---|
| ||
#include <signal.h>
#include <stdlib.h>
#include <string.h>
volatile sig_atomic_t sig1 = 0;
volatile sig_atomic_t sig2 = 0;
void sig1_handler(int signum) {
sig1 = 1;
}
void sig2_handler(int signum) {
sig2 = 1;
}
int main(void) {
signal(SIGUSR1, sig1_handler);
while (1) {
if (sig1) break;
sleep(SLEEP_TIME);
}
signal(SIGUSR2, sig2_handler);
while (1) {
if (sig2) break;
sleep(SLEEP_TIME);
}
/* ... */
return 0;
}
|
...