Gioviiz Gioviiz - 1 year ago 204
Python Question

python , launch an external program with ulimit

I need to launch an external program from my python script.
This program crashes, so I need to get a core dump from it.

what can i do?

Answer Source

Check out the python resource module. It will let you set the size of core files, etc., just like the ulimit command. Specifically, you want to do something like

resource.setrlimit(resource.RLIMIT_CORE, <size>)

before launching your target program.

My guess at usage (I haven't done this myself) is:

import resource
import subprocess

command = 'command line to be launched'
# os.system(command) would work, but os.system has been deprecated
# in favor of the subprocess module

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download