diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2018-04-07 15:12:57 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2018-04-07 15:12:57 +0200 |
commit | 6e1ab9aa550695ee7e3d467b4173c0b83ba7f759 (patch) | |
tree | 8fb7faa4364a7cbf1cba48296a5f537e13f2a8d9 /Src/Modules/system.c | |
parent | 5ad56a41f1ee2e61abca079f5ea8909f895ac2dd (diff) | |
parent | f027f1d6e876708bc75d4217e1ca26898658d8d3 (diff) | |
download | zsh-6e1ab9aa550695ee7e3d467b4173c0b83ba7f759.tar.gz zsh-6e1ab9aa550695ee7e3d467b4173c0b83ba7f759.zip |
Merge tag 'zsh-5.4.2-test-2' / 'upstream' branch into 'debian' branch
Test version 2 prior to zsh 5.5.
Diffstat (limited to 'Src/Modules/system.c')
-rw-r--r-- | Src/Modules/system.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Src/Modules/system.c b/Src/Modules/system.c index 3eecd7e95..9fd4d2583 100644 --- a/Src/Modules/system.c +++ b/Src/Modules/system.c @@ -649,22 +649,30 @@ 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) + if (errflag) { + zclose(flock_fd); return 1; + } if (errno != EINTR && errno != EACCES && errno != EAGAIN) { + zclose(flock_fd); zwarnnam(nam, "failed to lock file %s: %e", args[0], errno); return 1; } - if (time(NULL) >= end) + if (time(NULL) >= end) { + zclose(flock_fd); return 2; + } sleep(1); } } else { while (fcntl(flock_fd, timeout == 0 ? F_SETLK : F_SETLKW, &lck) < 0) { - if (errflag) + if (errflag) { + zclose(flock_fd); return 1; + } if (errno == EINTR) continue; + zclose(flock_fd); zwarnnam(nam, "failed to lock file %s: %e", args[0], errno); return 1; } |