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:
13
logging.c
13
logging.c
@@ -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
|
||||
|
Reference in New Issue
Block a user