Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict computing resources of a program?

Tags:

python

linux

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 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?

like image 470
user607722 Avatar asked Dec 02 '25 03:12

user607722


1 Answers

resource.setrlimit()

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