Report errors on handling the crash

ini_importer_tests
elsid 12 months ago
parent acb246cbf2
commit 4efc0e20a3
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -211,12 +211,12 @@ static void printGdbInfo(pid_t pid)
fflush(stdout); fflush(stdout);
} }
static void sys_info(void) static void printSystemInfo(void)
{ {
#ifdef __unix__ #ifdef __unix__
struct utsname info; struct utsname info;
if (uname(&info)) if (uname(&info) == -1)
printf("!!! Failed to get system information\n"); printf("Failed to get system information: %s\n", std::generic_category().message(errno).c_str());
else else
printf("System: %s %s %s %s %s\n", info.sysname, info.nodename, info.release, info.version, info.machine); printf("System: %s %s %s %s %s\n", info.sysname, info.nodename, info.release, info.version, info.machine);
@ -312,7 +312,8 @@ static void crash_catcher(int signum, siginfo_t* siginfo, void* /*context*/)
{ {
if (fread(&crash_info, sizeof(crash_info), 1, stdin) != 1) if (fread(&crash_info, sizeof(crash_info), 1, stdin) != 1)
{ {
fprintf(stderr, "!!! Failed to retrieve info from crashed process\n"); fprintf(stderr, "Failed to retrieve info from crashed process: %s\n",
std::generic_category().message(errno).c_str());
exit(1); exit(1);
} }
@ -347,7 +348,8 @@ static void crash_catcher(int signum, siginfo_t* siginfo, void* /*context*/)
/* Create crash log file and redirect shell output to it */ /* Create crash log file and redirect shell output to it */
if (freopen(logfile, "wa", stdout) != stdout) if (freopen(logfile, "wa", stdout) != stdout)
{ {
fprintf(stderr, "!!! Could not create %s following signal\n", logfile); fprintf(stderr, "Could not create %s following signal: %s\n", logfile,
std::generic_category().message(errno).c_str());
exit(1); exit(1);
} }
fprintf(stderr, "Generating %s and killing process %d, please wait... ", logfile, crash_info.pid); fprintf(stderr, "Generating %s and killing process %d, please wait... ", logfile, crash_info.pid);
@ -361,7 +363,7 @@ static void crash_catcher(int signum, siginfo_t* siginfo, void* /*context*/)
fputc('\n', stdout); fputc('\n', stdout);
fflush(stdout); fflush(stdout);
sys_info(); printSystemInfo();
fflush(stdout); fflush(stdout);

Loading…
Cancel
Save