From: nethack.allison Date: Sat, 25 Oct 2003 18:32:30 +0000 (+0000) Subject: handheld lockfile left around fix (from ) X-Git-Tag: MOVE2GIT~1635 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=125d1f1cf1b71a8b23fd2bda95784e209b4b3297;p=nethack handheld lockfile left around fix (from ) --- diff --git a/doc/fixes34.3 b/doc/fixes34.3 index be7db5dbe..13a7bedfe 100644 --- a/doc/fixes34.3 +++ b/doc/fixes34.3 @@ -102,6 +102,7 @@ Gnome: key values on unsigned char platform could fail to compare correctly Gnome: real extended command menu so all extended commands can be entered Gnome: ignore interrupts to avoid infinite loop in gnome library tty: avoid crash displaying quit inventory if inventory was already displayed +winCE: ensure orphaned lockfile is always deleted on single-user handhelds General New Features diff --git a/src/files.c b/src/files.c index 63f9d2f0e..2e8fb0fa2 100644 --- a/src/files.c +++ b/src/files.c @@ -1372,12 +1372,16 @@ int retryct; #define OPENFAILURE(fd) (fd < 0) lockptr = -1; # endif - while (retryct-- && OPENFAILURE(lockptr)) { -# ifdef AMIGA + while (--retryct && OPENFAILURE(lockptr)) { +# if defined(WIN32) && !defined(WIN_CE) + lockptr = sopen(lockname, O_RDWR|O_CREAT, SH_DENYRW, S_IWRITE); +# else (void)DeleteFile(lockname); /* in case dead process was here first */ +# ifdef AMIGA lockptr = Open(lockname,MODE_NEWFILE); -# else +# else lockptr = open(lockname, O_RDWR|O_CREAT|O_EXCL, S_IWRITE); +# endif # endif if (OPENFAILURE(lockptr)) { raw_printf("Waiting for access to %s. (%d retries left).",