diff options
author | Jan Dubois <jand@activestate.com> | 2009-11-12 17:14:59 -0800 |
---|---|---|
committer | Jan Dubois <jand@activestate.com> | 2009-11-12 17:15:30 -0800 |
commit | fd9e8b45c89ee5d36539a3655dae7737fb78c21e (patch) | |
tree | 3b1d7ec73442a501edb898fdc6ad275683464688 /pp_sys.c | |
parent | cbdd53315d32c50fe69953522ff12b867c3e7d66 (diff) | |
download | perl-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 */ |