diff --git a/src/core/sys/posix/fcntl.d b/src/core/sys/posix/fcntl.d index f4a9012d7b2..73e91af3ba8 100644 --- a/src/core/sys/posix/fcntl.d +++ b/src/core/sys/posix/fcntl.d @@ -486,6 +486,8 @@ else version( CRuntime_Bionic ) enum F_WRLCK = 1; enum F_UNLCK = 2; + enum LOCK_EX = 2; + version (X86) { enum O_CREAT = 0x40; // octal 0100 diff --git a/src/core/sys/posix/unistd.d b/src/core/sys/posix/unistd.d index 3c75aaff2ac..0b7f58566fd 100644 --- a/src/core/sys/posix/unistd.d +++ b/src/core/sys/posix/unistd.d @@ -1258,6 +1258,7 @@ else version( FreeBSD ) else version( CRuntime_Bionic ) { int fchdir(int) @trusted; + int flock(int, int) @trusted; pid_t getpgid(pid_t) @trusted; int lchown(in char*, uid_t, gid_t); int nice(int) @trusted; diff --git a/src/rt/cover.d b/src/rt/cover.d index 1df2606437c..9199d80a395 100644 --- a/src/rt/cover.d +++ b/src/rt/cover.d @@ -394,7 +394,9 @@ version (Windows) HANDLE handle(int fd) void lockFile(int fd) { - version (Posix) + version (CRuntime_Bionic) + core.sys.posix.unistd.flock(fd, LOCK_EX); // exclusive lock + else version (Posix) lockf(fd, F_LOCK, 0); // exclusive lock else version (Windows) {