2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

add fcntl locking

This commit is contained in:
Todd C. Miller
1999-08-06 13:49:26 +00:00
parent 925f4eabc2
commit 68a2b16781

View File

@@ -604,7 +604,18 @@ lock_file(fp, lockit)
FILE *fp;
int lockit;
{
/* XXX - implement fcntl-style locking */
#ifdef F_SETLK
struct flock lock;
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = getpid();
lock.l_type = lockit ? F_WRLCK : F_UNLCK;
lock.l_whence = SEEK_SET;
return(fcntl(fileno(fp), F_SETLKW, &lock) == 0);
#else
return(TRUE);
#endif
}
#endif