diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
new file mode 100644
index 775d71f..0309494
*** a/src/backend/utils/init/miscinit.c
--- b/src/backend/utils/init/miscinit.c
*************** CreateLockFile(const char *filename, boo
*** 766,771 ****
--- 766,793 ----
  							filename)));
  		close(fd);
  
+ 		if (len == 0)
+ 		{
+ 			/*
+ 			 *	An empty lock file exits;  either is it from another postmaster
+ 			 *	that is still starting up, or left from a crash.  Check for
+ 			 *	five seconds, then if it still empty, it must be from a crash,
+ 			 *	so fail and recommend lock file removal.
+ 			 */
+ 			if (ntries < 5)
+ 			{
+ 				sleep(1);
+ 				continue;
+ 			}
+ 			else
+ 				ereport(FATAL,
+ 						(errcode(ERRCODE_LOCK_FILE_EXISTS),
+ 						 errmsg("lock file \"%s\" is empty", filename),
+ 						 errhint(
+ 						"Empty lock file probably left from operating system crash during\n"
+ 						"database startup;  file deletion suggested.")));
+ 		}
+ 
  		buffer[len] = '\0';
  		encoded_pid = atoi(buffer);
  
