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) {