summaryrefslogtreecommitdiff
path: root/src/libstddjb/fd_unlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/fd_unlock.c')
-rw-r--r--src/libstddjb/fd_unlock.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libstddjb/fd_unlock.c b/src/libstddjb/fd_unlock.c
new file mode 100644
index 0000000..4c63fd9
--- /dev/null
+++ b/src/libstddjb/fd_unlock.c
@@ -0,0 +1,20 @@
+/* ISC license. */
+
+#include <fcntl.h>
+#include <errno.h>
+
+#include <skalibs/djbunix.h>
+
+void fd_unlock (int fd)
+{
+ struct flock 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 ;
+}