diff --git a/src/config.h b/src/config.h index 4b80e0c8..f910107a 100644 --- a/src/config.h +++ b/src/config.h @@ -11,7 +11,7 @@ #define VERSION "1.3.2" -#define BUILD 983 +#define BUILD 985 #define HOSTID "mailarchiver" diff --git a/src/errmsg.h b/src/errmsg.h index 860f6676..cb9df8b3 100644 --- a/src/errmsg.h +++ b/src/errmsg.h @@ -20,6 +20,7 @@ #define ERR_TIMED_OUT "ERR: timed out" #define ERR_FORK_FAILED "ERR: cannot fork()" #define ERR_OPEN_DEDUP_FILE "ERR: cannot open dedup file" +#define ERR_PID_FILE_EXISTS "ERR: pidfile exists. If piler daemon is not running, and the pidfile exists (unclean shutdown?) then remove it, and start piler again" #define ERR_MYSQL_CONNECT "Cannot connect to mysql server" #define ERR_PSQL_CONNECT "Cannot connect to PSql server" diff --git a/src/piler.c b/src/piler.c index 617c6053..534403a3 100644 --- a/src/piler.c +++ b/src/piler.c @@ -461,6 +461,7 @@ void initialise_configuration(){ int main(int argc, char **argv){ int i, daemonise=0, dedupfd; + struct stat st; while((i = getopt(argc, argv, "c:dvVh")) > 0){ @@ -509,6 +510,8 @@ int main(int argc, char **argv){ if(drop_privileges(pwd)) fatal(ERR_SETUID); + if(stat(cfg.pidfile, &st) == 0) fatal(ERR_PID_FILE_EXISTS); + if(cfg.mmap_dedup_test == 1){ dedupfd = open(MESSAGE_ID_DEDUP_FILE, O_RDWR); if(dedupfd == -1) fatal(ERR_OPEN_DEDUP_FILE);