about summary refs log tree commit diff
path: root/Src/Modules
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-09-11 17:22:02 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-09-11 17:22:02 -0700
commit26b4508ee339d834a500d940827b31c578d49e3e (patch)
tree67a33bff35ab0798cfee74c0e7d35d36d63e9205 /Src/Modules
parentef019506aeab44d830efccef27a7c9727156300c (diff)
downloadzsh-26b4508ee339d834a500d940827b31c578d49e3e.tar.gz
zsh-26b4508ee339d834a500d940827b31c578d49e3e.tar.xz
zsh-26b4508ee339d834a500d940827b31c578d49e3e.zip
39268: "zsystem flock -t 0 ..." tries only once to flock and immediately returns success or failure
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/system.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index 1ee61c00b..afaec262a 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -521,7 +521,7 @@ static int
 bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
 {
     int cloexec = 1, unlock = 0, readlock = 0;
-    time_t timeout = 0;
+    zlong timeout = -1;
     char *fdvar = NULL;
 #ifdef HAVE_FCNTL_H
     struct flock lck;
@@ -573,7 +573,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
 		} else {
 		    optarg = *args++;
 		}
-		timeout = (time_t)mathevali(optarg);
+		timeout = mathevali(optarg);
 		break;
 
 	    case 'u':
@@ -650,7 +650,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
 	    sleep(1);
 	}
     } else {
-	while (fcntl(flock_fd, F_SETLKW, &lck) < 0) {
+	while (fcntl(flock_fd, timeout == 0 ? F_SETLK : F_SETLKW, &lck) < 0) {
 	    if (errflag)
 		return 1;
 	    if (errno == EINTR)