mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-30 17:50:58 +01:00
27756: add OS file locking to calendar
add errflag test to loop over fcntl()
This commit is contained in:
parent
ecc7dc91f6
commit
07b6256d8e
7 changed files with 57 additions and 9 deletions
|
|
@ -463,6 +463,8 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
|
|||
if (timeout > 0) {
|
||||
time_t end = time(NULL) + (time_t)timeout;
|
||||
while (fcntl(flock_fd, F_SETLK, &lck) < 0) {
|
||||
if (errflag)
|
||||
return 1;
|
||||
if (errno != EINTR && errno != EACCES && errno != EAGAIN) {
|
||||
zwarnnam(nam, "failed to lock file %s: %e", args[0], errno);
|
||||
return 1;
|
||||
|
|
@ -473,6 +475,8 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
|
|||
}
|
||||
} else {
|
||||
while (fcntl(flock_fd, F_SETLKW, &lck) < 0) {
|
||||
if (errflag)
|
||||
return 1;
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
zwarnnam(nam, "failed to lock file %s: %e", args[0], errno);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue