3 ms·
Infinite loop after exit(0)
- nazri1 9y agoFo those who didn't read the linked thread, here's the nugget (answered by Ian Lance Taylor): > 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'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.
- wddps 9y agoDoesnt this just mean it never received the exit call