Changeset 5723 for lm-sensors/trunk/prog/sensord/sensord.c
- Timestamp:
- 05/13/09 18:11:57 (4 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/prog/sensord/sensord.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/prog/sensord/sensord.c
r5722 r5723 66 66 static void signalHandler(int sig) 67 67 { 68 signal(sig, signalHandler);69 68 switch (sig) { 70 69 case SIGTERM: … … 148 147 } 149 148 149 static void install_sighandler(void) 150 { 151 struct sigaction new; 152 int ret; 153 154 memset(&new, 0, sizeof(struct sigaction)); 155 new.sa_handler = signalHandler; 156 sigemptyset(&new.sa_mask); 157 new.sa_flags = SA_RESTART; 158 159 ret = sigaction(SIGTERM, &new, NULL); 160 if (ret == -1) { 161 fprintf(stderr, "Could not set sighandler for SIGTERM: %s\n", 162 strerror(errno)); 163 exit(EXIT_FAILURE); 164 } 165 166 ret = sigaction(SIGHUP, &new, NULL); 167 if (ret == -1) { 168 fprintf(stderr, "Could not set sighandler for SIGHUP: %s\n", 169 strerror(errno)); 170 exit(EXIT_FAILURE); 171 } 172 } 173 150 174 static void daemonize(void) 151 175 { … … 173 197 } 174 198 175 /* I should use sigaction but... */ 176 if (signal(SIGTERM, signalHandler) == SIG_ERR || 177 signal (SIGHUP, signalHandler) == SIG_ERR) { 178 perror("signal"); 179 exit(EXIT_FAILURE); 180 } 199 install_sighandler(); 181 200 182 201 if ((pid = fork()) == -1) {
