From c7f8ef5508e13ac348d54045070699f58f3e31a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Wed, 13 Nov 2024 00:56:30 -0300 Subject: [PATCH] Issue #83, handle EINTR correctly (?) --- src/eepp/system/process.cpp | 10 ++++++---- src/tools/ecode/ecode.cpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/eepp/system/process.cpp b/src/eepp/system/process.cpp index cd96ba8c5..aa91f4115 100644 --- a/src/eepp/system/process.cpp +++ b/src/eepp/system/process.cpp @@ -319,10 +319,11 @@ size_t Process::readAll( std::string& buffer, bool readErr, Time timeout ) { buffer.resize( mBufferSize ); bool anyOpen = pollfd.fd != -1; ssize_t n = 0; - while ( anyOpen && !mShuttingDown && isAlive() && errno != EINTR ) { + while ( anyOpen && !mShuttingDown && isAlive() ) { int res = poll( &pollfd, static_cast( 1 ), 100 ); if ( res <= 0 ) { - if ( timeout != Time::Zero && clock.getElapsedTime() >= timeout ) + if ( ( timeout != Time::Zero && clock.getElapsedTime() >= timeout ) || + ( res < 0 && errno != EINTR ) ) break; continue; } @@ -419,7 +420,7 @@ void Process::startAsyncRead( ReadFn readStdOut, ReadFn readStdErr ) { std::string buffer; buffer.resize( mBufferSize ); bool anyOpen = !pollfds.empty(); - while ( anyOpen && !mShuttingDown && errno != EINTR ) { + while ( anyOpen && !mShuttingDown ) { int res = poll( pollfds.data(), static_cast( pollfds.size() ), 100 ); if ( res > 0 ) { anyOpen = false; @@ -447,7 +448,8 @@ void Process::startAsyncRead( ReadFn readStdOut, ReadFn readStdErr ) { anyOpen = true; } } - } + } else if ( res < 0 && errno != EINTR ) + break; } } ); #endif diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 6bdb19aec..716d669f9 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -793,7 +793,7 @@ void App::onFileDropped( std::string file ) { UITab* tab = mSplitter->isDocumentOpen( file ); UICodeEditor* codeEditor = nullptr; - if ( tab ) { + if ( tab && tab->getTabWidget() ) { tab->getTabWidget()->setTabSelected( tab ); return; }