go1.12.1源代码中,/src/runtime/proc.go文件中
func main()函数的最后一段代码如图所示,不明白这么写的目的是什么。。。
![2019-03-29 16 24 48.jpg](https://static.studygolang.com/190329/14521047fcc7e7f26c6c3db3dc867c12.jpg)
更多评论
Ian Taylor的回复:
“The runtime is a special case in many ways, and this is among the more
special parts. This loop exists to catch problems while testing new
ports. If that loop is ever reached, something has gone badly wrong:
the exit call should have caused the program to exit. We can't assume
that panic is working. We can't really assume that anything is
working. What we want to do is stop the program. Since exit failed,
it's possible that a nil dereference will succeed. If that fails too,
we still have to do something, so we just loop. We can't return
because this is the main function that started the program; there is
nothing to return to.”
[链接](https://groups.google.com/forum/#!msg/golang-nuts/FnF3oZeJ7aY/sLz0G3oDAgAJ)
#1