From 62ce9d45d4e28651c20a3d1176106106a658ef5a Mon Sep 17 00:00:00 2001 From: "Colin B. Macdonald" Date: Thu, 4 Jan 2024 21:52:47 -0800 Subject: [PATCH 1/2] handle the impossible (?) errno zero case in the same block Too annoying to maintain two code paths for something that should never happen. --- inst/private/readblock.m | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/inst/private/readblock.m b/inst/private/readblock.m index c148a113a..222ec5241 100644 --- a/inst/private/readblock.m +++ b/inst/private/readblock.m @@ -60,19 +60,23 @@ done = true; end - elseif (errno() == EAGAIN || errno() == EINVAL) + elseif (errno () == EAGAIN || errno () == EINVAL || errno () == 0) + if (errno () >= 0) + warning ('OctSymPy:readblock:invaliderrno', ... + 'error with errno = 0: shouldn''t that be impossible?') + end % with these coefficients, we check about 90 times before the display % starts at 8 seconds; at that time the waitdelta is approx 1 second. % We cap the waiting at 1 second (Issue #1255). - waitdelta = min(1, exp(nwaits/10)/1e4); + waitdelta = min (1, exp (nwaits/10)/1e4); if (time() - start <= wait_disp_thres) % no-op elseif (~dispw) - fprintf(stdout, 'Waiting...') + fprintf (stdout, 'Waiting...') dispw = true; else if nwaits - skip >= lastdot - fprintf(stdout, '.') + fprintf (stdout, '.') lastdot = nwaits; % Don't draw every second; increase the number of seconds to skip skip = skip + 1; @@ -84,26 +88,6 @@ %end pause (waitdelta); nwaits = nwaits + 1; - elseif (errno() == 0) - waitdelta = min(1, exp(nwaits/10)/1e4); - if (time() - start <= wait_disp_thres) - % no-op - elseif (~dispw) - fprintf(stdout, '[usually something wrong if you see stars] Waiting***') - dispw = true; - else - if nwaits - skip >= lastdot - fprintf(stdout, '*') - lastdot = nwaits; - skip = skip + 1; - end - end - fclear (fout); - %if (ispc () && (~isunix ())) - %errno (0); % maybe can do this on win32? - %end - pause (waitdelta); - nwaits = nwaits + 1; else warning ('OctSymPy:readblock:invaliderrno', ... sprintf('readblock: s=%d, errno=%d, perhaps error in the command?', s, errno())) From 7604e5f9469e79b9c2d334e90dc01e4d666e7834 Mon Sep 17 00:00:00 2001 From: "Colin B. Macdonald" Date: Fri, 5 Jan 2024 17:29:43 -0800 Subject: [PATCH 2/2] Just let the catch-all handle the errno zero case --- inst/private/readblock.m | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/inst/private/readblock.m b/inst/private/readblock.m index 222ec5241..29a37102b 100644 --- a/inst/private/readblock.m +++ b/inst/private/readblock.m @@ -60,11 +60,7 @@ done = true; end - elseif (errno () == EAGAIN || errno () == EINVAL || errno () == 0) - if (errno () >= 0) - warning ('OctSymPy:readblock:invaliderrno', ... - 'error with errno = 0: shouldn''t that be impossible?') - end + elseif (errno () == EAGAIN || errno () == EINVAL) % with these coefficients, we check about 90 times before the display % starts at 8 seconds; at that time the waitdelta is approx 1 second. % We cap the waiting at 1 second (Issue #1255). @@ -91,7 +87,7 @@ else warning ('OctSymPy:readblock:invaliderrno', ... sprintf('readblock: s=%d, errno=%d, perhaps error in the command?', s, errno())) - pause(0.1) % FIXME; replace with waitdelta etc + pause (1) end %disp('paused'); pause