From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1833 invoked from network); 27 Jun 2020 07:14:55 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 27 Jun 2020 07:14:55 -0000 Received: (qmail 27292 invoked by alias); 27 Jun 2020 07:14:47 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: Sender: zsh-workers@zsh.org X-Seq: 46143 Received: (qmail 23502 invoked by uid 1010); 27 Jun 2020 07:14:46 -0000 X-Qmail-Scanner-Diagnostics: from nef2.ens.fr by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25850. spamassassin: 3.4.4. Clear:RC:0(129.199.96.40):SA:0(-4.2/5.0):. Processed in 4.462189 secs); 27 Jun 2020 07:14:46 -0000 X-Envelope-From: ware@phare.normalesup.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at ens.fr designates 129.199.96.40 as permitted sender) X-ENS-nef-client: 129.199.129.80 Date: Sat, 27 Jun 2020 09:13:50 +0200 From: Cedric Ware To: Bart Schaefer Cc: Daniel Shahaf , Sebastian Gniazdowski , Zsh hackers list Subject: Re: [BUG] zsystem:34: flock: invalid timeout value: '0' Message-ID: <20200627071350.zqkdhzbk3mfej2tz@phare.normalesup.org> References: <20200626141644.7cb5e511@tarpaulin.shahaf.local2> <20200627014717.68986199@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Sat, 27 Jun 2020 09:13:51 +0200 (CEST) Hello, Bart Schaefer (Friday 2020-06-26): > It's pretty obvious that the patch caused the change: > > + if (timeout < 1e-6 || timeout > 1073741823.) { > + zwarnnam(nam, "flock: invalid timeout value: '%s'", > + optarg); Yes, sorry, didn't catch the 0 case. > Similarly: > > + if (timeout_param.u.d < 1 > + || timeout_param.u.d > 0.999 * LONG_MAX) { > + zwarnnam(nam, "flock: invalid interval value: '%s'", > + optarg); I don't think so. This one is for the -i parameter, which is new, it's not a behavior change. And IMO it doesn't make sense to allow a zero interval. > I don't know enough about dealing with the float-valued time specs to be > sure what to do about it, i.e., why a limit above zero was considered > necessary or whether zero needs to be a special case. I didn't want to allow specifying a timeout below 1 microsecond, because that's the granularity of zsleep(). One could still allow it but silently treat it as 0. In any case, the 0 value itself should indeed have been allowed. Here's a quick patch below, I've tested it, but I don't have time right now to do much more. Best regards, Cedric Ware. diff --git a/Src/Modules/system.c b/Src/Modules/system.c index 972aa0767..638fe029e 100644 --- a/Src/Modules/system.c +++ b/Src/Modules/system.c @@ -591,13 +591,16 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) timeout_param.u.d : (double)timeout_param.u.l; /* + * timeout can be 0 (no wait) but not so small as to be + * less than a microsecond. * timeout must not overflow time_t, but little is known * about this type's limits. Conservatively limit to 2^30-1 * (34 years). Then it can only overflow if time_t is only * a 32-bit int and CLOCK_MONOTONIC is not supported, in which * case there is a Y2038 problem anyway. */ - if (timeout < 1e-6 || timeout > 1073741823.) { + if (timeout != 0. && + (timeout < 1e-6 || timeout > 1073741823.)) { zwarnnam(nam, "flock: invalid timeout value: '%s'", optarg); return 1; diff --git a/Test/V14system.ztst b/Test/V14system.ztst index b8af96cda..06512fe05 100644 --- a/Test/V14system.ztst +++ b/Test/V14system.ztst @@ -13,7 +13,9 @@ %test ( - zsystem flock -t 0.1 -i 0.000001 $tst_dir/file + zsystem flock -t 0 -i 0.000001 $tst_dir/file && + zsystem flock -t 0.1 -i 0.000001 $tst_dir/file && + zsystem flock -t 1 -i 0.000001 $tst_dir/file ) 0:zsystem flock valid time arguments