added pidfile check in piler.c to prevent multiple start of the piler daemon

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2018-01-11 10:56:32 +01:00
parent e03a9f2982
commit bef68aec3a
3 changed files with 5 additions and 1 deletions

View File

@ -11,7 +11,7 @@
#define VERSION "1.3.2"
#define BUILD 983
#define BUILD 985
#define HOSTID "mailarchiver"

View File

@ -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"

View File

@ -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);