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 3258 invoked from network); 27 Jun 2020 07:28:02 -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:28:02 -0000 Received: (qmail 5969 invoked by alias); 27 Jun 2020 07:27:53 -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: 46145 Received: (qmail 20382 invoked by uid 1010); 27 Jun 2020 07:27:53 -0000 X-Qmail-Scanner-Diagnostics: from mail-il1-f182.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.166.182):SA:0(-2.0/5.0):. Processed in 1.62733 secs); 27 Jun 2020 07:27:53 -0000 X-Envelope-From: roman.perepelitsa@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.166.182 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=972X+tSBoueqfRG+eP0nc9WtqeI3rZt5gCdCq/szuPc=; b=id9Vt+g4CCbXPfmNrjQ/vYRizUqWRQ1zpcfwUWXa6SMxVlw6xt+Rgs8ZSIwT+A2TnV WhpPyAIuCBvWoZVVpdbVYH4NK0ceOzoM8YeoaRXGuVmQjRlr7/nBHx2kxodVpEewRyfK JG3kg3DFv5UofgtRiUZuRtr0/ppI1KfTcbuTtEP5w/ZX61acDWqTgITAiZm1yhSkmrVh ELp/nasCAkwr2vrD8PTcqlvbdRwbFa6VL95D5psJvjfuipkm6/hIviZsg6q85Lvqapr2 RQCQqMRGJj6A4scOoCNWhfnNAyAMA25aAaTI57mCYst39vVB0kF/KhSEmSQXQEBXDywo WcxQ== X-Gm-Message-State: AOAM530+vgFbZuh3jvrzx9qiIPFyMTcOmyKbLTCJz2HwgsacLC4IT7Te wZ33Fg45kAsC2OnYdagb11hSqRGV7FiV6s+Hics= X-Google-Smtp-Source: ABdhPJw5T/jSrX5SsrmN1WMcRM5wb6l1TnY/r7V8jkRoE8GAsvwXBWV5pK6Fjk7VrvJxd4bBj2O/O+y0LDBBIg2Y7g0= X-Received: by 2002:a92:bf0c:: with SMTP id z12mr6558358ilh.151.1593242839433; Sat, 27 Jun 2020 00:27:19 -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: Roman Perepelitsa Date: Sat, 27 Jun 2020 09:27:08 +0200 Message-ID: Subject: Re: [BUG] zsystem:34: flock: invalid timeout value: '0' To: Cedric Ware Cc: Bart Schaefer , Daniel Shahaf , Sebastian Gniazdowski , Zsh hackers list Content-Type: text/plain; charset="UTF-8" On Sat, Jun 27, 2020 at 9:14 AM Cedric Ware wrote: > > 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. Timeout strictly between 0 and 1 microsecond is not much different from timeout between 1 and 2 microseconds. You can either round up or down in both cases. Rounding up is the right thing to do for sleeps and timeouts because it allows you to provide a guarantee. For sleep (pseudo code): time start = now(); if (sleep(duration) != INTERRUPTED) assert(now - start() >= duration); For anything with a timeout (pseudo code): time start = now(); if (do_with_timeout(duration) == TIMEDOUT) assert(now - start() >= duration); If you round down, there is no non-trivial assertion that is guaranteed to hold and that doesn't expose the internal granularity of the duration. Roman.