mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Report postmaster.pid file as empty if it is empty, rather than
reporting in contains invalid data.
This commit is contained in:
@ -766,6 +766,14 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
|||||||
filename)));
|
filename)));
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
{
|
||||||
|
ereport(FATAL,
|
||||||
|
(errcode(ERRCODE_LOCK_FILE_EXISTS),
|
||||||
|
errmsg("lock file \"%s\" is empty", filename),
|
||||||
|
errhint("Either another server is starting, or the lock file is the remnant of a previous server startup crash.")));
|
||||||
|
}
|
||||||
|
|
||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
encoded_pid = atoi(buffer);
|
encoded_pid = atoi(buffer);
|
||||||
|
|
||||||
|
@ -292,8 +292,13 @@ get_pgpid(void)
|
|||||||
}
|
}
|
||||||
if (fscanf(pidf, "%ld", &pid) != 1)
|
if (fscanf(pidf, "%ld", &pid) != 1)
|
||||||
{
|
{
|
||||||
write_stderr(_("%s: invalid data in PID file \"%s\"\n"),
|
/* Is the file empty? */
|
||||||
progname, pid_file);
|
if (ftell(pidf) == 0 && feof(pidf))
|
||||||
|
write_stderr(_("%s: the PID file \"%s\" is empty\n"),
|
||||||
|
progname, pid_file);
|
||||||
|
else
|
||||||
|
write_stderr(_("%s: invalid data in PID file \"%s\"\n"),
|
||||||
|
progname, pid_file);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fclose(pidf);
|
fclose(pidf);
|
||||||
|
Reference in New Issue
Block a user