diff options
author | Woongsuk Cho <ws77.cho@samsung.com> | 2018-08-10 10:19:39 +0900 |
---|---|---|
committer | 조웅석/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <ws77.cho@samsung.com> | 2018-09-06 10:22:00 +0900 |
commit | 7028d11e9b94aa16d99a804f258a6e055a553181 (patch) | |
tree | 61bdedf10ccf4e421f2c162bacf29653995c854b | |
parent | e7026b9f41af58aac0040ca51aa1a478af574e17 (diff) | |
download | launcher-7028d11e9b94aa16d99a804f258a6e055a553181.tar.gz launcher-7028d11e9b94aa16d99a804f258a6e055a553181.tar.bz2 launcher-7028d11e9b94aa16d99a804f258a6e055a553181.zip |
use write function instead of fprintf in the signal handler
Change-Id: Idb95796bc59841a3ffa325272ffe983fe893d43a
-rw-r--r-- | NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index d33c0d7..f5a43da 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -127,34 +127,37 @@ struct sigaction sig_abrt_old; static bool checkOnSigabrt = false; static void onSigabrt(int signum) { - fprintf(stderr, "onSigabrt is called!!!\n"); - - if (checkOnSigabrt) { - fprintf(stderr, "SIGABRT is already handled. Go to exit\n"); - exit(0); - } - - if (hasException()) { - fprintf(stderr, "Unhandled exception is occured. Ignore coredump creation and terminate normally\n"); - exit(0); - } else { - fprintf(stderr, "SIGABRT from native. raise(%d)\n", signum); - checkOnSigabrt = true; + // ignore return value of write(). + // this function is called when process go to die + // there is no need to handle return value for logging. + write(2, "onSigabrt called\n", 17); + + if (checkOnSigabrt) { + write(2, "onSigabrt called again. go to exit\n", 35); + exit(0); + } + + if (hasException()) { + write(2, "Unhandled exception is occured. Ignore coredump creation and terminate normally\n", 80); + exit(0); + } else { + write(2, "SIGABRT from native. raise SIGABRT\n", 35); + checkOnSigabrt = true; if (sigaction(SIGABRT, &sig_abrt_old, NULL) == 0) { if (raise(signum) < 0) { - fprintf(stderr, "Fail to raise SIGABRT\n"); + write(2, "Fail to raise SIGABRT\n", 22); } } else { - fprintf(stderr, "Fail to set original SIGABRT handler\n"); + write(2, "Fail to set original SIGABRT handler\n", 37); } - } + } } static void registerSigHandler() { sig_abrt_new.sa_handler = onSigabrt; - if (sigemptyset(&sig_abrt_new.sa_mask) == 0) { - _ERR("Fail to initialize signal set"); + if (sigemptyset(&sig_abrt_new.sa_mask) != 0) { + _ERR("Fail to sigemptyset"); } if (sigaction(SIGABRT, &sig_abrt_new, &sig_abrt_old) < 0) { |