At pgpool startup, if pid file exists, truncate pid file to zero length before writing.
authorBo Peng <pengbo@sraoss.co.jp>
Wed, 12 Aug 2020 07:07:04 +0000 (16:07 +0900)
committerBo Peng <pengbo@sraoss.co.jp>
Wed, 12 Aug 2020 07:16:45 +0000 (16:16 +0900)
Patch is created by maliangzhu.

src/main/main.c

index d7fce18d630ad862343a230b93f0ca4316827a1f..f966cf4302f48edbc120722144eec133dd8503ba 100644 (file)
@@ -560,7 +560,7 @@ static void write_pid_file(void)
                                                pool_config->pid_file_name)));
        }
 
-       fd = open(pid_file, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR);
+       fd = open(pid_file, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
        if (fd == -1)
        {
                ereport(FATAL,