From 5e8b7e4f356c2908bb3389e2df09473e290acae8 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Mon, 25 Aug 2014 17:07:37 -0400 Subject: [PATCH] Define default pidfile when creating pid We want pidfile to be NULL on startup so we can detect if the user set an explicit value versus only using the default value. Closes #1967 Fixes #2076 --- src/redis.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/redis.c b/src/redis.c index 52e00b56..fd0d39bb 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1433,7 +1433,7 @@ void initServerConfig(void) { server.aof_flush_postponed_start = 0; server.aof_rewrite_incremental_fsync = REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC; server.aof_load_truncated = REDIS_DEFAULT_AOF_LOAD_TRUNCATED; - server.pidfile = zstrdup(REDIS_DEFAULT_PID_FILE); + server.pidfile = NULL; server.rdb_filename = zstrdup(REDIS_DEFAULT_RDB_FILENAME); server.aof_filename = zstrdup(REDIS_DEFAULT_AOF_FILENAME); server.requirepass = NULL; @@ -3393,6 +3393,10 @@ void linuxMemoryWarnings(void) { #endif /* __linux__ */ void createPidFile(void) { + /* If pidfile requested, but no pidfile defined, use + * default pidfile path */ + if (!server.pidfile) server.pidfile = zstrdup(REDIS_DEFAULT_PID_FILE); + /* Try to write the pid file in a best-effort way. */ FILE *fp = fopen(server.pidfile,"w"); if (fp) {