diff options
author | Russ Cox <rsc@golang.org> | 2010-07-26 16:52:51 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-07-26 16:52:51 -0700 |
commit | 059bb40a7ca50a4184eddd2814a6641db766087b (patch) | |
tree | fd2740131fece03427969d3a81b97a18baaf248c | |
parent | db89eb98c22377eb204f9c2d8664a4edd5fe7352 (diff) | |
download | go-059bb40a7ca50a4184eddd2814a6641db766087b.tar.gz |
gc: graceful exit on seg fault
R=ken2
CC=golang-dev
http://codereview.appspot.com/1882043
-rw-r--r-- | src/cmd/gc/lex.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c index 7c9fb07dd..726cab753 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 = "\"\""; |