Is it possible to force a core dump in a program, and still have the program
continue running? Forcing a core dump is easy with something like:
{
char *dump=0;
sprintf(dump, "This will segfault");
The best idea I've had is something like:Quote:}
void
dump_core()
{
switch(fork()) {
case -1:
exit(errno);
break;
case 0:
{
char *dump=0;
sprintf(dump, "This will segfault");
break;
}
default:
return;
}
This will cause the program to fork, and the child can then dump core. TheQuote:}
parent is then allowed to continue running. Is there a better way to do this?
Breif rational for trying this:
I want to write a sighandler that catches Seg-faults, bus errors, etc. and dumps
core so I can debug the program and find the error. But I want the program to
re-exec itself also to attempt some sort of recovery from the error.
Eric
--------------------------------+------------------------------------------
Eric Boyd (TSMA) | "It's easier to ask for
InterDimensions Corp. | forgiveness than for permission."
25 Ellery St. |
Cambridge Ma, 02138 | "640K ought to be enough for anybody."
617-661-4200 | -- Bill Gates, 1981
|