开发者

How to restrict computing resources of a program?

开发者 https://www.devze.com 2023-03-02 18:22 出处:网络
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 resour

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

精彩评论

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