summaryrefslogtreecommitdiff
path: root/zen/process_exec.cpp
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2021-04-05 11:02:07 -0400
committerB Stack <bgstack15@gmail.com>2021-04-05 11:02:07 -0400
commit74361d859354e4416285cd803b1b0075be1fe514 (patch)
treedafb5e266c513a5ed9863401e62d246742861e0c /zen/process_exec.cpp
parentMerge branch '11.7' into 'master' (diff)
downloadFreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.tar.gz
FreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.tar.bz2
FreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.zip
add upstream 11.9
Diffstat (limited to 'zen/process_exec.cpp')
-rw-r--r--zen/process_exec.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/zen/process_exec.cpp b/zen/process_exec.cpp
index b82c2565..f51ceae2 100644
--- a/zen/process_exec.cpp
+++ b/zen/process_exec.cpp
@@ -81,11 +81,11 @@ std::pair<int /*exit code*/, std::string> processExecuteImpl(const Zstring& file
if (::pipe2(pipe, O_CLOEXEC) != 0)
THROW_LAST_SYS_ERROR("pipe2");
-
const int fdLifeSignR = pipe[0]; //for parent process
const int fdLifeSignW = pipe[1]; //for child process
ZEN_ON_SCOPE_EXIT(::close(fdLifeSignR));
auto guardFdLifeSignW = makeGuard<ScopeGuardRunMode::onExit>([&] { ::close(fdLifeSignW ); });
+
//--------------------------------------------------------------
//follow implemenation of ::system(): https://github.com/lattera/glibc/blob/master/sysdeps/posix/system.c
@@ -237,14 +237,17 @@ void zen::openWithDefaultApp(const Zstring& itemPath) //throw FileError
{
try
{
- const Zstring cmdTemplate = R"(xdg-open "%x")"; //doesn't block => no need for time out!
+ std::optional<int> timeoutMs;
+ const Zstring cmdTemplate = R"(xdg-open "%x")"; //*might* block!
+ timeoutMs = 0; //e.g. on Lubuntu if Firefox is started and not already running => no need time out! https://freefilesync.org/forum/viewtopic.php?t=8260
const Zstring cmdLine = replaceCpy(cmdTemplate, Zstr("%x"), itemPath);
- if (const auto& [exitCode, output] = consoleExecute(cmdLine, std::nullopt /*timeoutMs*/); //throw SysError, (SysErrorTimeOut)
+ if (const auto& [exitCode, output] = consoleExecute(cmdLine, timeoutMs); //throw SysError, SysErrorTimeOut
exitCode != 0)
throw SysError(formatSystemError(utfTo<std::string>(cmdTemplate),
replaceCpy(_("Exit code %x"), L"%x", numberTo<std::wstring>(exitCode)), utfTo<std::wstring>(output)));
}
+ catch (SysErrorTimeOut&) {} //child process not failed yet => probably fine :>
catch (const SysError& e) { throw FileError(replaceCpy(_("Cannot open file %x."), L"%x", fmtPath(itemPath)), e.toString()); }
}
bgstack15