1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-23 15:08:37 +00:00

Merge pull request #4162 from magnumripper/robust-lock

Recover from (rare) non-fatal file locking problems
This commit is contained in:
Jens Steube 2025-05-28 20:47:56 +02:00 committed by GitHub
commit 4df5e4517d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,9 +20,18 @@ int hc_lockfile (HCFILE *fp)
lock.l_type = F_WRLCK;
/* Needs this loop because a signal may interrupt a wait for lock */
while (fcntl (fp->fd, F_SETLKW, &lock))
{
// These shouldn't happen with F_SETLKW yet are (rarely) seen IRL. Recoverable!
if (errno == EAGAIN || errno == ENOLCK)
{
struct timeval tv = { .tv_sec = 0, .tv_usec = 10000 };
select (0, NULL, NULL, NULL, &tv);
continue;
}
// A signal may interrupt a wait for lock with EINTR. Anything else is fatal
if (errno != EINTR) return -1;
}