I created a web-application to compile and run code. How can I check if a user enters an infinite loop. I want to check at runtime if the code runs for longer than 20 seconds and then abort the computation.
Asked
Active
Viewed 144 times
0
-
What is "code.c"? What operating system do you want your application to run on? – Feb 16 '12 at 08:53
1 Answers
0
The easiest way is to spawn an external process, get a process handle, and then you can wait on this process to finish or kill it after 20 seconds. The actual functions you need to call depend on which OS your web server is running.
Having said this, allowing web site users to upload code and execute it, is a HUGE security risk. Your authentication and trust in these users has to be very high. If it is a public web site, JUST DON'T DO IT!

mikijov
- 1,552
- 24
- 37