summaryrefslogtreecommitdiffabout
path: root/src/main.c
Side-by-side diff
Diffstat (limited to 'src/main.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/main.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 01a24a9..13d9818 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,10 +1,11 @@
#include "varnish_mib.h"
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
+#include <string.h>
char *progname;
static void pidfile_check(char const *pid_file);
static void pidfile_create(char const *pid_file);
static int pidfile_remove(char const *pid_file);
@@ -171,13 +172,12 @@ main(int argc, char **argv)
if (post_config())
exit(1);
pidfile_check(pid_file);
if (!foreground) {
- int i;
if (daemon(0, 1)) {
fprintf(stderr, "%s: daemon: %s\n",
progname, strerror(errno));
exit(1);
}
openlog(progname, LOG_CONS|LOG_PID, LOG_DAEMON);
@@ -227,13 +227,12 @@ pidfile_create(char const *pid_file)
return;
fp = fopen(pid_file, "w");
if (!fp) {
snmp_log(LOG_CRIT,
"cannot create pidfile `%s': %s\n",
- progname,
pid_file,
strerror(errno));
exit(1);
}
fprintf(fp, "%lu\n", (unsigned long) getpid());
fclose(fp);
@@ -252,13 +251,13 @@ pidfile_check(char const *pid_file)
fp = fopen(pid_file, "r");
if (fp) {
if (fscanf(fp, "%lu", &pid) != 1) {
snmp_log(LOG_ERR,
- "cannot get pid from pidfile `%s'\n",
+ "cannot get pid from pidfile `%s': %s\n",
pid_file,
strerror(errno));
} else {
if (kill(pid, 0) == 0) {
snmp_log(LOG_ERR,
"%s appears to run with pid %lu. "

Return to:

Send suggestions and report system problems to the System administrator.