summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeir Shpilraien (Spielrein) <meir@redislabs.com>2020-12-22 15:17:39 +0200
committerOran Agra <oran@redislabs.com>2021-02-22 23:22:53 +0200
commit35da4aee7e0c69520cf030144a1541d0b966af08 (patch)
treea3e957ad7b42ec6bde212edfdd924a92f6f74a2b
parente4ab38a3e440f945229fd9e4379b3f98aca2345e (diff)
downloadredis-35da4aee7e0c69520cf030144a1541d0b966af08.tar.gz
Fix issue where fork process deletes the parent pidfile (#8231)
Turns out that when the fork child crashes, the crash log was deleting the pidfile from the disk (although the parent is still running. Now we set the pidfile of the fork process to NULL so the fork process will never deletes it. (cherry picked from commit 92a483bca2df734aff5caada6c23409ed6256773)
-rw-r--r--src/debug.c2
-rw-r--r--src/server.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/debug.c b/src/debug.c
index 1ec7c4977..351d749a8 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -1335,7 +1335,7 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
);
/* free(messages); Don't call free() with possibly corrupted memory. */
- if (server.daemonize && server.supervised == 0) unlink(server.pidfile);
+ if (server.daemonize && server.supervised == 0 && server.pidfile) unlink(server.pidfile);
/* Make sure we exit with the right signal at the end. So for instance
* the core will be dumped if enabled. */
diff --git a/src/server.c b/src/server.c
index 68fa089ac..874b0af91 100644
--- a/src/server.c
+++ b/src/server.c
@@ -4043,6 +4043,10 @@ void closeClildUnusedResourceAfterFork() {
closeListeningSockets(0);
if (server.cluster_enabled && server.cluster_config_file_lock_fd != -1)
close(server.cluster_config_file_lock_fd); /* don't care if this fails */
+
+ /* Clear server.pidfile, this is the parent pidfile which should not
+ * be touched (or deleted) by the child (on exit / crash) */
+ server.pidfile = NULL;
}
void memtest(size_t megabytes, int passes);