diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-02-14 16:07:19 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-02-14 16:10:39 +0200 |
commit | 2d2e9e1fdadb5af7bfd5a2a77500218b592034e1 (patch) | |
tree | 01aab262490eeff1dcea109767719ba1f84b50fc /src | |
parent | fe4dd5c7fe77591ee8d7780d3f5e2e9b9334c2c5 (diff) | |
download | varnish-mib-2d2e9e1fdadb5af7bfd5a2a77500218b592034e1.tar.gz varnish-mib-2d2e9e1fdadb5af7bfd5a2a77500218b592034e1.tar.bz2 |
Version 4.0release-4.0
* Makefile.am: Add init.
* NEWS: Update.
* README: Mention initialization files from init.
* configure.ac: Version 4.0
* init/README: New file.
* init/debian: New file.
* init/rh: New file.
* init/slackware: New file.
* init/slackware.genrc: New file.
* init/varnish-mib.service: New file.
* src/main.c: Minor fixes.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -1,10 +1,11 @@ | |||
1 | #include "varnish_mib.h" | 1 | #include "varnish_mib.h" |
2 | #include <unistd.h> | 2 | #include <unistd.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <signal.h> | 4 | #include <signal.h> |
5 | #include <string.h> | ||
5 | 6 | ||
6 | char *progname; | 7 | char *progname; |
7 | 8 | ||
8 | static void pidfile_check(char const *pid_file); | 9 | static void pidfile_check(char const *pid_file); |
9 | static void pidfile_create(char const *pid_file); | 10 | static void pidfile_create(char const *pid_file); |
10 | static int pidfile_remove(char const *pid_file); | 11 | static int pidfile_remove(char const *pid_file); |
@@ -171,13 +172,12 @@ main(int argc, char **argv) | |||
171 | if (post_config()) | 172 | if (post_config()) |
172 | exit(1); | 173 | exit(1); |
173 | 174 | ||
174 | pidfile_check(pid_file); | 175 | pidfile_check(pid_file); |
175 | 176 | ||
176 | if (!foreground) { | 177 | if (!foreground) { |
177 | int i; | ||
178 | if (daemon(0, 1)) { | 178 | if (daemon(0, 1)) { |
179 | fprintf(stderr, "%s: daemon: %s\n", | 179 | fprintf(stderr, "%s: daemon: %s\n", |
180 | progname, strerror(errno)); | 180 | progname, strerror(errno)); |
181 | exit(1); | 181 | exit(1); |
182 | } | 182 | } |
183 | openlog(progname, LOG_CONS|LOG_PID, LOG_DAEMON); | 183 | openlog(progname, LOG_CONS|LOG_PID, LOG_DAEMON); |
@@ -227,13 +227,12 @@ pidfile_create(char const *pid_file) | |||
227 | return; | 227 | return; |
228 | 228 | ||
229 | fp = fopen(pid_file, "w"); | 229 | fp = fopen(pid_file, "w"); |
230 | if (!fp) { | 230 | if (!fp) { |
231 | snmp_log(LOG_CRIT, | 231 | snmp_log(LOG_CRIT, |
232 | "cannot create pidfile `%s': %s\n", | 232 | "cannot create pidfile `%s': %s\n", |
233 | progname, | ||
234 | pid_file, | 233 | pid_file, |
235 | strerror(errno)); | 234 | strerror(errno)); |
236 | exit(1); | 235 | exit(1); |
237 | } | 236 | } |
238 | fprintf(fp, "%lu\n", (unsigned long) getpid()); | 237 | fprintf(fp, "%lu\n", (unsigned long) getpid()); |
239 | fclose(fp); | 238 | fclose(fp); |
@@ -252,13 +251,13 @@ pidfile_check(char const *pid_file) | |||
252 | 251 | ||
253 | fp = fopen(pid_file, "r"); | 252 | fp = fopen(pid_file, "r"); |
254 | 253 | ||
255 | if (fp) { | 254 | if (fp) { |
256 | if (fscanf(fp, "%lu", &pid) != 1) { | 255 | if (fscanf(fp, "%lu", &pid) != 1) { |
257 | snmp_log(LOG_ERR, | 256 | snmp_log(LOG_ERR, |
258 | "cannot get pid from pidfile `%s'\n", | 257 | "cannot get pid from pidfile `%s': %s\n", |
259 | pid_file, | 258 | pid_file, |
260 | strerror(errno)); | 259 | strerror(errno)); |
261 | } else { | 260 | } else { |
262 | if (kill(pid, 0) == 0) { | 261 | if (kill(pid, 0) == 0) { |
263 | snmp_log(LOG_ERR, | 262 | snmp_log(LOG_ERR, |
264 | "%s appears to run with pid %lu. " | 263 | "%s appears to run with pid %lu. " |