From 33bcd9e2d6a1e332c2a47a85eb6a81da6e393cbb 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 52e00b560..fd0d39bb8 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) {