1

What is the best way to run an executable with execution-time and memory(RAM) limit (e.g. 2.5 seconds and 32768 kB)?

I need to get the exit-code if it exits without violating time and memory limits. Otherwise it should be killed and I need to know which limit it violated (e.g. MEMORY_LIMIT_EXCEEDED, TIME_LIMIT_EXCEEDED).

1 Answer 1

2

I'd recommend this nice tool, it'll limit CPU time or memory consumption:

https://github.com/pshved/timeout

5
  • Will it work on windows too if I install Perl? Mar 11, 2014 at 9:01
  • No it won't, after looking at the code it uses pure unix/posix calls. Mar 11, 2014 at 9:05
  • Is there anything like this but that will work for both Linux and Windows? I want to write an [OJ][1] which will work both for Windows and Linux. [1]: http://en.wikipedia.org/wiki/Online_judge Mar 11, 2014 at 9:13
  • Sure I will. :) Mar 11, 2014 at 9:15
  • Is it possible to disallow child processes? Mar 11, 2014 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .