Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Allow zsystem flock to query without second-lasting timeout



Hello,
attached patch is dumb, and allows to use negative timeout, which
results in a quick (non-waiting) single fcntl() call. Such timeout can
already be passed to zsystem flock, because (Src/Modules/system.c):

                timeout = (time_t)mathevali(optarg);

and time_t is signed on Darwin, a linux box that a person tested and I
guess it's always signed because "time can be negative" – but a
knowledge here would be needed.

Best regards,
Sebastian Gniazdowski
diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index 1ee61c0..2769f75 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -636,7 +636,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
     lck.l_start = 0;
     lck.l_len = 0;  /* lock the whole file */
 
-    if (timeout > 0) {
+    if (timeout != 0) {
 	time_t end = time(NULL) + (time_t)timeout;
 	while (fcntl(flock_fd, F_SETLK, &lck) < 0) {
 	    if (errflag)


Messages sorted by: Reverse Date, Date, Thread, Author