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=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29919 invoked from network); 27 Jun 2020 17:26:18 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 27 Jun 2020 17:26:18 -0000 Received: (qmail 26395 invoked by alias); 27 Jun 2020 17:26:11 -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: 46149 Received: (qmail 24212 invoked by uid 1010); 27 Jun 2020 17:26:11 -0000 X-Qmail-Scanner-Diagnostics: from mail-vs1-f46.google.com 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(209.85.217.46):SA:0(-2.0/5.0):. Processed in 2.432365 secs); 27 Jun 2020 17:26:11 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.217.46 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2jcMG9FLgzkOsaDB5s52av2BRqhqsl163xHV+vVqtfg=; b=gB6kqZr60E5YFLGQCLWldnKxdoLxNnZJQbwjZ7FfYW5X2zJSDURMqawkI9DisjhOeL fPxWfmhEZaV2BoO4P7VAAmuod9sTDJhf03dcGvZQPmK0t9zSGKTK2SvU7ifaCwfpM/8j E3OPCnKsWD91cAvTFG9eIxZgdggFs1wjkq13mg70FXESb4s41cMy+sL23qddoFdmvs7J yh7LzRYWXok8X/g/7jFDO8Y4/C974xulqTlugCdDTYwEvyFsXsDAcNMFgQZdgFtEitar byOiezy+38HWC5Q41zTl59fZBwjJ/mff8yj21L3BmXGIMWb7Qpx0YhQ3lv9byQIOnXMs 55+Q== X-Gm-Message-State: AOAM532f4arYqOuwS5GutbmVwVUNPUCE/8/BbW9vyciFBYqjQC2GO11W ayhBKJnfnzlybWqDrRrl0xNSLvxDn3HcEr5xus4= X-Google-Smtp-Source: ABdhPJyTmXdxqwgb/n9mjbmA1/Xte1A60aPgT+c07KvDKFg5Lq6/3gV0nV7NYXgCE0qCBOGbRy6tlROHGfgj6zDp4ZA= X-Received: by 2002:a67:fd75:: with SMTP id h21mr6480730vsa.77.1593278735662; Sat, 27 Jun 2020 10:25:35 -0700 (PDT) MIME-Version: 1.0 References: <20200626141644.7cb5e511@tarpaulin.shahaf.local2> <20200627014717.68986199@tarpaulin.shahaf.local2> <20200627071350.zqkdhzbk3mfej2tz@phare.normalesup.org> In-Reply-To: <20200627071350.zqkdhzbk3mfej2tz@phare.normalesup.org> From: Sebastian Gniazdowski Date: Sat, 27 Jun 2020 19:25:28 +0200 Message-ID: Subject: Re: [BUG] zsystem:34: flock: invalid timeout value: '0' To: Cedric Ware Cc: Bart Schaefer , Daniel Shahaf , Zsh hackers list Content-Type: multipart/alternative; boundary="00000000000011440605a9141daa" --00000000000011440605a9141daa Content-Type: text/plain; charset="UTF-8" The patch looks good to me. On Sat, 27 Jun 2020 at 09:13, Cedric Ware wrote: > > 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 > > -- Sebastian Gniazdowski IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zinit Blog: http://zdharma.org --00000000000011440605a9141daa--