1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-15 20:39:17 +00:00
hashcat/src/locking.c
jsteube 3daf0af480 Added docs/credits.txt
Added docs/team.txt
2016-09-11 22:20:15 +02:00

43 lines
650 B
C

/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "logging.h"
#include "locking.h"
#if defined (F_SETLKW)
void lock_file (FILE *fp)
{
struct flock lock;
memset (&lock, 0, sizeof (struct flock));
lock.l_type = F_WRLCK;
while (fcntl (fileno (fp), F_SETLKW, &lock))
{
if (errno != EINTR)
{
log_error ("ERROR: Failed acquiring write lock: %s", strerror (errno));
exit (-1);
}
}
}
void unlock_file (FILE *fp)
{
struct flock lock;
memset (&lock, 0, sizeof (struct flock));
lock.l_type = F_UNLCK;
fcntl (fileno (fp), F_SETLK, &lock);
}
#endif // F_SETLKW