]> granicus.if.org Git - nethack/commitdiff
Fix error behaviour when perm is missing
authorAlex Smith <ais523@nethack4.org>
Fri, 1 Sep 2017 16:43:04 +0000 (17:43 +0100)
committerAlex Smith <ais523@nethack4.org>
Fri, 1 Sep 2017 16:43:04 +0000 (17:43 +0100)
The previous behaviour was to mention the missing file, but then to
try and fail to lock the nonexistent file 10 times, which rather
obscured the original cause of the error as it took up so much more
room on the screen.

This patch also changes the error message. Failure to lock a
nonexistent file is almost always the result of a mistake during
the install process (e.g. running from the wrong directory, or
running without an install). We should give the user a hint about
that.

src/files.c

index 1c55133cb5c82429f984d7fd44e18dd4dbe0c38b..970734024a8a8947281750b303136d690f15e8a2 100644 (file)
@@ -1643,8 +1643,9 @@ int retryct;
 #ifdef USE_FCNTL
     lockfd = open(filename, O_RDWR);
     if (lockfd == -1) {
-        HUP raw_printf("Cannot open file %s. This is a program bug.",
+        HUP raw_printf("Cannot open file %s. Is NetHack installed correctly?",
                        filename);
+        return FALSE;
     }
     sflock.l_type = F_WRLCK;
     sflock.l_whence = SEEK_SET;