use write function instead of fprintf in the signal handler
authorWoongsuk Cho <ws77.cho@samsung.com>
Fri, 10 Aug 2018 01:19:39 +0000 (10:19 +0900)
committer조웅석/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <ws77.cho@samsung.com>
Thu, 6 Sep 2018 01:22:00 +0000 (10:22 +0900)
Change-Id: Idb95796bc59841a3ffa325272ffe983fe893d43a

NativeLauncher/launcher/dotnet/dotnet_launcher.cc

index d33c0d7..f5a43da 100644 (file)
@@ -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) {