diff options
author | Cedric Ware <cedric.ware__bml@normalesup.org> | 2020-07-11 00:14:58 -0500 |
---|---|---|
committer | dana <dana@dana.is> | 2020-07-11 00:14:58 -0500 |
commit | 4d7aa71d8ed64827df4d8efd993abffcbc0fc075 (patch) | |
tree | fe9f73b6fe5aea9654f5ade10c1fb4ff1c08563b /Src/Modules/system.c | |
parent | c04a39187704e2b46a46f9aeee370365aeff4b1f (diff) | |
download | zsh-4d7aa71d8ed64827df4d8efd993abffcbc0fc075.tar.gz zsh-4d7aa71d8ed64827df4d8efd993abffcbc0fc075.tar.xz zsh-4d7aa71d8ed64827df4d8efd993abffcbc0fc075.zip |
46152: zsh/system: Re-allow '0' timeout in zsystem flock
Diffstat (limited to 'Src/Modules/system.c')
-rw-r--r-- | Src/Modules/system.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Src/Modules/system.c b/Src/Modules/system.c index 972aa0767..ecd4e2546 100644 --- a/Src/Modules/system.c +++ b/Src/Modules/system.c @@ -597,7 +597,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) * 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 > 1073741823.) { zwarnnam(nam, "flock: invalid timeout value: '%s'", optarg); return 1; @@ -623,7 +623,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) timeout_param.type = MN_FLOAT; timeout_param.u.d = (double)timeout_param.u.l; } - timeout_param.u.d *= 1e6; + timeout_param.u.d = ceil(timeout_param.u.d * 1e6); if (timeout_param.u.d < 1 || timeout_param.u.d > 0.999 * LONG_MAX) { zwarnnam(nam, "flock: invalid interval value: '%s'", @@ -704,7 +704,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) zgettime_monotonic_if_available(&now); end.tv_sec = now.tv_sec; end.tv_nsec = now.tv_nsec; - end.tv_nsec += modf(timeout, &timeout_s) * 1000000000L; + end.tv_nsec += ceil(modf(timeout, &timeout_s) * 1000000000L); end.tv_sec += timeout_s; if (end.tv_nsec >= 1000000000L) { end.tv_nsec -= 1000000000L; |