summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2009-11-12 17:14:59 -0800
committerJan Dubois <jand@activestate.com>2009-11-12 17:15:30 -0800
commitfd9e8b45c89ee5d36539a3655dae7737fb78c21e (patch)
tree3b1d7ec73442a501edb898fdc6ad275683464688 /pp_sys.c
parentcbdd53315d32c50fe69953522ff12b867c3e7d66 (diff)
downloadperl-fd9e8b45c89ee5d36539a3655dae7737fb78c21e.tar.gz
flock() should return EWOULDBLOCK instead of EAGAIN.
POSIX requires fcntl() to return EAGAIN or EACCES, whereas BSD requires flock() to return EWOULDBLOCK. On most systems EAGAIN and EWOULDBLOCK use the same number, but on some (e.g. Linux on PA-RISC) they do not.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index a985d658cd..bea4b7d47e 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -5579,6 +5579,7 @@ PP(pp_syscall)
static int
fcntl_emulate_flock(int fd, int operation)
{
+ int res;
struct flock flock;
switch (operation & ~LOCK_NB) {
@@ -5598,7 +5599,10 @@ fcntl_emulate_flock(int fd, int operation)
flock.l_whence = SEEK_SET;
flock.l_start = flock.l_len = (Off_t)0;
- return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &flock);
+ res = fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &flock);
+ if (res == -1 && ((errno == EAGAIN) || (errno == EACCES)))
+ errno = EWOULDBLOCK;
+ return res;
}
#endif /* FCNTL_EMULATE_FLOCK */