Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3825963

Browse files
committed
Report postmaster.pid file as empty if it is empty, rather than
reporting in contains invalid data.
1 parentc82dedb commit3825963

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎src/backend/utils/init/miscinit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,14 @@ CreateLockFile(const char *filename, bool amPostmaster,
766766
filename)));
767767
close(fd);
768768

769+
if (len==0)
770+
{
771+
ereport(FATAL,
772+
(errcode(ERRCODE_LOCK_FILE_EXISTS),
773+
errmsg("lock file \"%s\" is empty",filename),
774+
errhint("Either another server is starting, or the lock file is the remnant of a previous server startup crash.")));
775+
}
776+
769777
buffer[len]='\0';
770778
encoded_pid=atoi(buffer);
771779

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,13 @@ get_pgpid(void)
292292
}
293293
if (fscanf(pidf,"%ld",&pid)!=1)
294294
{
295-
write_stderr(_("%s: invalid data in PID file \"%s\"\n"),
296-
progname,pid_file);
295+
/* Is the file empty? */
296+
if (ftell(pidf)==0&&feof(pidf))
297+
write_stderr(_("%s: the PID file \"%s\" is empty\n"),
298+
progname,pid_file);
299+
else
300+
write_stderr(_("%s: invalid data in PID file \"%s\"\n"),
301+
progname,pid_file);
297302
exit(1);
298303
}
299304
fclose(pidf);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp