diff options
| author | LeRoyce Pearson <leroycepearson@geemili.xyz> | 2020-04-02 22:57:02 -0600 |
|---|---|---|
| committer | LeRoyce Pearson <leroycepearson@geemili.xyz> | 2020-04-02 22:57:02 -0600 |
| commit | ea6525797d0db83a8560179b317837cb58634049 (patch) | |
| tree | 48a190000f83ba3303a9a3cae797430303c883b9 /lib/std/os/linux.zig | |
| parent | e7cf3f92a98cd2bd94d9d94fb361819b6ab89e8d (diff) | |
| download | zig-ea6525797d0db83a8560179b317837cb58634049.tar.gz zig-ea6525797d0db83a8560179b317837cb58634049.zip | |
Use `flock` instead of `fcntl` to lock files
`flock` locks based on the file handle, instead of the process id.
This brings the file locking on unix based systems closer to file
locking on Windows.
Diffstat (limited to 'lib/std/os/linux.zig')
| -rw-r--r-- | lib/std/os/linux.zig | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 1ed8370274..87ee198985 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -592,6 +592,10 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize { return syscall3(.fcntl, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, cmd)), arg); } +pub fn flock(fd: fd_t, operation: i32) usize { + return syscall2(.flock, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, operation))); +} + var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime); // We must follow the C calling convention when we call into the VDSO |
