aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstddjb/fd_unlock.c
blob: f9758b505ea8bd97455d0eade2d8cc3bc0ffa4db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ISC license. */

#include <unistd.h>
#include <errno.h>

#include <skalibs/fcntl.h>
#include <skalibs/djbunix.h>

void fd_unlock (int fd)
{
  static struct flock const fl =
  {
    .l_type = F_UNLCK,
    .l_whence = SEEK_SET,
    .l_start = 0,
    .l_len = 0
  } ;
  int e = errno ;
  fcntl(fd, F_SETLK, &fl) ;
  errno = e ;
}