user607722
user607722

Reputation: 1676

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

Upvotes: 3

Views: 311

Answers (3)

daveagp
daveagp

Reputation: 2669

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.

Upvotes: 0

S.Lott
S.Lott

Reputation: 391952

Linux ulimit.

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

Upvotes: 0

user2665694
user2665694

Reputation:

resource.setrlimit()

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

Upvotes: 2

Related Questions