From: Russ Cox Date: Mon, 26 Jul 2010 23:52:51 +0000 (-0700) Subject: gc: graceful exit on seg fault X-Git-Tag: weekly.2010-07-29~31 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b49561d884237703732a34a047cf7fe1f1373946;p=gostls13.git gc: graceful exit on seg fault R=ken2 CC=golang-dev https://golang.org/cl/1882043 --- diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c index 7c9fb07dd6..726cab7533 100644 --- a/src/cmd/gc/lex.c +++ b/src/cmd/gc/lex.c @@ -90,12 +90,27 @@ usage(void) exit(0); } +void +fault(int s) +{ + // If we've already complained about things + // in the program, don't bother complaining + // about the seg fault too; let the user clean up + // the code and try again. + if(nerrors > 0) + errorexit(); + fatal("fault"); +} + int main(int argc, char *argv[]) { int i, c; NodeList *l; char *p; + + signal(SIGBUS, fault); + signal(SIGSEGV, fault); localpkg = mkpkg(strlit("")); localpkg->prefix = "\"\"";