They don't. The program runs in your browser. It isn't their problem if it contains an infinite loop. If the page stops responding, you simply reload the page.
Programming contests use a check program that has a time limit on program execution.
Programming contests use a check program that has a time limit on program execution.
while(true){}
the page loads but the ide says time limit exceeded after 5 seconds and stops the execution. Now, how do you do that?
executeUserProgram(userProgram, timeout=5)...
alternatively, the server on which the user program runs could monitor user processes and terminate any process using excessive CPU time.Both approaches look for the effects of an infinite loop instead of the program logic of an infinite loop. Which makes sense since logical analysis for infinite loops is the Halting Problem and NP-Hard.
executeUserProgram()
Is an abstraction. I made up the name to explain how the behavior might be implemented in the abstract. Implementing the abstraction in a way appropriate for an actual program is software engineering based on the actual program's actual constraints.