The user program containing the while-loop could be executed with a system call as:
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.