DumpStackFrameInfo(" ", stack[i]);
}
#endif
+
+ // *** TRANSITION ***
+ //
+ // BEFORE this point, all code must be async-termination-safe!
+ // (See WARNING above.)
+ //
+ // AFTER this point, we do unsafe things, like using LOG()!
+ // The process could be terminated or hung at any time. We try to
+ // do more useful things first and riskier things later.
+
+ // Flush the logs before we do anything in case 'anything'
+ // causes problems.
+ FlushLogFilesUnsafe(0);
+
// Kill ourself by the default signal handler.
InvokeDefaultSignalHandler(signal_number);
}
InstallFailureSignalHandler();
const std::string command = argc > 1 ? argv[1] : "none";
if (command == "segv") {
+ // We'll check if this is outputted.
+ LOG(INFO) << "create the log file";
+ LOG(INFO) << "a message before segv";
// We assume 0xDEAD is not writable.
int *a = (int*)0xDEAD;
*a = 0;
LIBGLOG="$BINDIR/libglog.so"
BINARY="$BINDIR/signalhandler_unittest"
+LOG_INFO="./signalhandler_unittest.INFO"
# Remove temporary files.
rm -f signalhandler.out*
fi
# Test for a case the program kills itself by SIGSEGV.
-$BINARY segv 2> signalhandler.out1
+GOOGLE_LOG_DIR=. $BINARY segv 2> signalhandler.out1
for pattern in SIGSEGV 0xdead main "Aborted at [0-9]"; do
if ! grep --quiet "$pattern" signalhandler.out1; then
die "'$pattern' should appear in the output"
fi
done
+if ! grep --quiet "a message before segv" $LOG_INFO; then
+ die "'a message before segv' should appear in the INFO log"
+fi
+rm -f $LOG_INFO
# Test for a case the program is killed by this shell script.
# $! = the process id of the last command run in the background.