diff options
author | B Stack <bgstack15@gmail.com> | 2020-09-01 00:24:17 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-09-01 00:24:17 +0000 |
commit | 5a3f52b016581a6a0cb4513614b6c620d365dde2 (patch) | |
tree | acfdfb3e1046db87040477033fda0df76d92916a /zen/shell_execute.cpp | |
parent | Merge branch '11.0' into 'master' (diff) | |
parent | add upstream 11.1 (diff) | |
download | FreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.tar.gz FreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.tar.bz2 FreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.zip |
Merge branch '11.1' into 'master'11.1
add upstream 11.1
See merge request opensource-tracking/FreeFileSync!25
Diffstat (limited to 'zen/shell_execute.cpp')
-rw-r--r-- | zen/shell_execute.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/zen/shell_execute.cpp b/zen/shell_execute.cpp index 90ccfdf3..241b9786 100644 --- a/zen/shell_execute.cpp +++ b/zen/shell_execute.cpp @@ -89,7 +89,7 @@ std::pair<int /*exit code*/, std::wstring> zen::consoleExecute(const Zstring& cm THROW_LAST_SYS_ERROR("open"); auto guardTmpFile = makeGuard<ScopeGuardRunMode::onExit>([&] { ::close(fdTempFile); }); - //"deleting while handles are open" == FILE_FLAG_DELETE_ON_CLOSE + //"deleting while handle is open" == FILE_FLAG_DELETE_ON_CLOSE if (::unlink(tempFilePath.c_str()) != 0) THROW_LAST_SYS_ERROR("unlink"); @@ -158,11 +158,16 @@ std::pair<int /*exit code*/, std::wstring> zen::consoleExecute(const Zstring& cm guardFdLifeSignW.dismiss(); ::close(fdLifeSignW); //[!] make sure we get EOF when fd is closed by child! - if (::fcntl(fdLifeSignR, F_SETFL, O_NONBLOCK) != 0) - THROW_LAST_SYS_ERROR("fcntl(O_NONBLOCK)"); + const int flags = ::fcntl(fdLifeSignR, F_GETFL); + if (flags == -1) + THROW_LAST_SYS_ERROR("fcntl(F_GETFL)"); + + if (::fcntl(fdLifeSignR, F_SETFL, flags | O_NONBLOCK) == -1) + THROW_LAST_SYS_ERROR("fcntl(F_SETFL, O_NONBLOCK)"); + const auto endTime = std::chrono::steady_clock::now() + std::chrono::milliseconds(*timeoutMs); - for (;;) //EINTR handling? => allow interrupt!? + for (;;) //EINTR handling? => allow interruption!? { //read until EAGAIN char buf[16]; |