1
0
mirror of https://github.com/golang/go synced 2024-11-26 01:07:57 -07:00

runtime: make return from main wait for active panic

Arguably if this happens the program is buggy anyway,
but letting the panic continue looks better than interrupting it.
Otherwise things like this are possible, and confusing:

$ go run x.go
panic: $ echo $?
0
$

Fixes #3934.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7322083
This commit is contained in:
Russ Cox 2013-02-15 14:48:35 -05:00
parent 2d4164596f
commit c8214c78bd

View File

@ -253,6 +253,14 @@ runtime·main(void)
main·main();
if(raceenabled)
runtime·racefini();
// Make racy client program work: if panicking on
// another goroutine at the same time as main returns,
// let the other goroutine finish printing the panic trace.
// Once it does, it will exit. See issue 3934.
if(runtime·panicking)
runtime·park(nil, nil, "panicwait");
runtime·exit(0);
for(;;)
*(int32*)runtime·main = 0;