Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Replace use of lockf with flock for Bionic
Browse files Browse the repository at this point in the history
  • Loading branch information
joakim-noah committed May 28, 2015
1 parent 7d25976 commit 0a8b4b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/core/sys/posix/fcntl.d
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/core/sys/posix/unistd.d
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/rt/cover.d
Expand Up @@ -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)
{
Expand Down

0 comments on commit 0a8b4b8

Please sign in to comment.