Improve best-effort logging before termination on OOM

Suggested by @kallewoof in bitcoin/bitcoin#9856
This commit is contained in:
Jack Grigg 2018-04-23 10:39:23 +01:00
parent d207b81d28
commit 3c9dbf3ed8
No known key found for this signature in database
GPG Key ID: 665DBCD284F7DAFF
1 changed files with 1 additions and 0 deletions

View File

@ -730,6 +730,7 @@ bool AppInitServers(boost::thread_group& threadGroup)
// Since LogPrintf may itself allocate memory, set the handler directly
// to terminate first.
std::set_new_handler(std::terminate);
fputs("Error: Out of memory. Terminating.\n", stderr);
LogPrintf("Error: Out of memory. Terminating.\n");
// The log was successful, terminate now.