How to limit the size of subprocess stdout and stderr in python
I need to run applications submitted by users. My code looks like: def run_app(app_path): inp = open("app.in", "r") otp = open("app.out", "w") return subprocess.call(app_path, stdout=otp, stdin=inp) Now since I have no control over what users will submit, I want to restrict the size of the output of the application. Other things like trying to access unauthorized system resources and abusing of CPU cycles are being restricted by apparmor rule enforcement. The maximum time allowed to run is being handled by parent process (in python). Now a rogue application can still try to flood the server