Detect and log errors in crash_dump()

This commit is contained in:
Markus Armbruster 2008-04-25 22:09:52 +02:00
parent f55860670a
commit dd0737f8e7

View file

@ -40,6 +40,9 @@
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#ifndef _WIN32
#include <sys/wait.h>
#endif
#include <unistd.h> #include <unistd.h>
#if defined(_WIN32) #if defined(_WIN32)
@ -315,9 +318,29 @@ ignore(void)
static void static void
crash_dump(void) crash_dump(void)
{ {
#ifndef _WIN32 #ifdef _WIN32
if (fork() == 0) logerror("Crash dump is not implemented");
abort(); #else
pid_t pid;
int status;
pid = fork();
if (pid < 0) {
logerror("Can't fork for crash dump (%s)", strerror(errno));
return;
}
if (pid == 0)
abort(); /* child */
/* parent */
while (waitpid(pid, &status, 0) < 0) {
if (errno != EINTR) {
logerror("Can't get crash dumping child's status (%s)",
strerror(errno));
return;
}
}
logerror("Crash dump complete");
#endif #endif
} }