aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-07-26 16:52:51 -0700
committerRuss Cox <rsc@golang.org>2010-07-26 16:52:51 -0700
commitb49561d884237703732a34a047cf7fe1f1373946 (patch)
treeb7dd1e43d737d1f3b1a3e3b1ab94940e2daa2505
parenta59e113fcb5bd4ccb6870c43a7b5e36e746b5567 (diff)
downloadgo-b49561d884237703732a34a047cf7fe1f1373946.tar.gz
go-b49561d884237703732a34a047cf7fe1f1373946.zip
gc: graceful exit on seg fault
R=ken2 CC=golang-dev https://golang.org/cl/1882043
-rw-r--r--src/cmd/gc/lex.c15
1 files changed, 15 insertions, 0 deletions
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 = "\"\"";