开发者

How to restrict computing resources of a program?

I wish to implement an online judge system in Linux using python. I need to restrict computing resource(time, memory) for process. Process should terminate when it uses开发者_StackOverflow more resources than given.

Also, when a program terminates, I need to know whether it terminates normally, or terminates because of run time error (stack over flow, divide by zero, accessing invalid address), or using more resource than given.

How to do it in python?


resource.setrlimit()

http://docs.python.org/library/resource.html


Linux ulimit.

http://linux.die.net/man/1/ulimit


There is a "safeexec" program on github that does a pretty decent job of this. It is pretty fidgety to get it working from scratch.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜