Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Allow zsystem flock to query without second-lasting timeout
- X-seq: zsh-workers 39266
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] Allow zsystem flock to query without second-lasting timeout
- Date: Sat, 10 Sep 2016 17:49:30 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=AOcWmGBwiobvH9zRHvavH3n4y3GbGYn9riacAFJSaUE=; b=lmHH9fX7oOwNqtJbAerGI0NWesCIN3wYtRRwVLoMp5ij587E7Za6c02ahnxSS+66Hr 7qCrh+pDX+viisQ0PvUZVtIL8TJyTYWBYuVYaQZZSIJW8NI++h8/q0Uh1QlyKXN/06ja OtBSRGyJCUSZfIPT6Ot7ghigNQ1ogrA+/0Ivwvsfweg3/VivE5MwqH/1DclNZSTYDasy KFAk+fEyoc8QdijCBuLQO6VU9SowVUG0TBdlmwpRVZVSVrTsTHKq3yi9wFMidgPYQvrP v0waZR83ofslZWakhPiaTorFMT0H97dznw5CTlpOMh0MQEsl6m/7QYara3cl9mO6eOBy oxQg==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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