| ... | @@ -1140,24 +1140,13 @@ pub fn freeNullDelimitedEnvMap(allocator: *mem.Allocator, envp_buf: []?[*:0]u8) | ... | @@ -1140,24 +1140,13 @@ pub fn freeNullDelimitedEnvMap(allocator: *mem.Allocator, envp_buf: []?[*:0]u8) |
| 1140 | allocator.free(envp_buf); | 1140 | allocator.free(envp_buf); |
| 1141 | } | 1141 | } |
| 1142 | | 1142 | |
| 1143 | pub const LockCmd = enum { | | |
| 1144 | GetLock, | | |
| 1145 | SetLock, | | |
| 1146 | SetLockBlocking, | | |
| 1147 | }; | | |
| 1148 | | | |
| 1149 | pub const FcntlError = error{ | 1143 | pub const FcntlError = error{ |
| 1150 | /// The file is locked by another process | 1144 | /// The file is locked by another process |
| 1151 | FileLocked, | 1145 | FileLocked, |
| 1152 | } || UnexpectedError; | 1146 | } || UnexpectedError; |
| 1153 | | 1147 | |
| 1154 | /// Attempts to get lock the file, blocking if the file is locked. | 1148 | /// Attempts to get lock the file, blocking if the file is locked. |
| 1155 | pub fn fcntlFlock(fd: fd_t, lock_cmd: LockCmd, flock_p: *Flock) FcntlError!void { | 1149 | pub fn fcntl(fd: fd_t, cmd: i32, flock_p: *Flock) FcntlError!void { |
| 1156 | const cmd: i32 = switch (lock_cmd) { | | |
| 1157 | .GetLock => F_GETLK, | | |
| 1158 | .SetLock => F_SETLK, | | |
| 1159 | .SetLockBlocking => F_SETLKW, | | |
| 1160 | }; | | |
| 1161 | while (true) { | 1150 | while (true) { |
| 1162 | switch (errno(system.fcntl(fd, cmd, flock_p))) { | 1151 | switch (errno(system.fcntl(fd, cmd, flock_p))) { |
| 1163 | 0 => return, | 1152 | 0 => return, |