From 578af10bba1560a6af945f46a17091cb9c66a81f Mon Sep 17 00:00:00 2001 From: Jan Olszak Date: Wed, 12 Dec 2012 09:04:48 +0100 Subject: [PATCH] [Prevent] Handle unhandled exceptions in wrt-installer. [Issue] Unhandled exceptions propagate to main(). [Bug] N/A [Cause] N/A [Solution] Catch all exceptions and log them. [Verification] Build installer. Change-Id: Ic5f43397c404bdab609884638099b24bbd8a7dc1 --- src/wrt-installer/wrt_installer.cpp | 74 +++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/src/wrt-installer/wrt_installer.cpp b/src/wrt-installer/wrt_installer.cpp index fd6f903..297ec7b 100644 --- a/src/wrt-installer/wrt_installer.cpp +++ b/src/wrt-installer/wrt_installer.cpp @@ -926,44 +926,48 @@ bool WrtInstaller::popupsEnabled() const int main(int argc, char *argv[]) { - // Output on stdout will be flushed after every newline character, - // even if it is redirected to a pipe. This is useful for running - // from a script and parsing output. - // (Standard behavior of stdlib is to use full buffering when - // redirected to a pipe, which means even after an end of line - // the output may not be flushed). - setlinebuf(stdout); - - // Check and re-set the file open limitation - struct rlimit rlim; - if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) { - LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" ); - LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" ); - - if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) { - rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER; - rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER; - if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) { - LogError("setrlimit is fail!!"); + UNHANDLED_EXCEPTION_HANDLER_BEGIN + { + // Output on stdout will be flushed after every newline character, + // even if it is redirected to a pipe. This is useful for running + // from a script and parsing output. + // (Standard behavior of stdlib is to use full buffering when + // redirected to a pipe, which means even after an end of line + // the output may not be flushed). + setlinebuf(stdout); + + // Check and re-set the file open limitation + struct rlimit rlim; + if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) { + LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" ); + LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" ); + + if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) { + rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER; + rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER; + if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) { + LogError("setrlimit is fail!!"); + } } + } else { + LogError("getrlimit is fail!!"); } - } else { - LogError("getrlimit is fail!!"); - } - // set evas backend type for emulator - // popup isn't showed in the emulator, - // if backend isn't set to SW backend - if (GlobalSettings::IsEmulator()) { - if (setenv("ELM_ENGINE", "x11", 1)) { - LogDebug("Enable backend"); + // set evas backend type for emulator + // popup isn't showed in the emulator, + // if backend isn't set to SW backend + if (GlobalSettings::IsEmulator()) { + if (setenv("ELM_ENGINE", "x11", 1)) { + LogDebug("Enable backend"); + } } - } - WrtInstaller app(argc, argv); - int ret = app.Exec(); - LogDebug("App returned: " << ret); - ret = app.getReturnStatus(); - LogDebug("WrtInstaller returned: " << ret); - return ret; + WrtInstaller app(argc, argv); + int ret = app.Exec(); + LogDebug("App returned: " << ret); + ret = app.getReturnStatus(); + LogDebug("WrtInstaller returned: " << ret); + return ret; + } + UNHANDLED_EXCEPTION_HANDLER_END } -- 2.7.4