TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Infinite loop after exit(0)

3 pointsby nazri1almost 8 years ago

1 comment

nazri1almost 8 years ago
Fo those who didn&#x27;t read the linked thread, here&#x27;s the nugget (answered by Ian Lance Taylor):<p><pre><code> &gt; Why not just panic, though? And why the infinite loop, I wonder? 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&#x27;t assume that panic is working. We can&#x27;t really assume that anything is working. What we want to do is stop the program. Since exit failed, it&#x27;s possible that a nil dereference will succeed. If that fails too, we still have to do something, so we just loop. We can&#x27;t return because this is the main function that started the program; there is nothing to return to.</code></pre>
评论 #14587481 未加载