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?
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?
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
resource.setrlimit(resource.RLIMIT_CORE,
(resource.RLIM_INFINITY,
resource.RLIM_INFINITY))
command = 'command line to be launched'
subprocess.call(command)
# os.system(command) would work, but os.system has been deprecated
# in favor of the subprocess module