0

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?

Michal Gallovic
  • 4,109
  • 2
  • 18
  • 25
Gioviiz
  • 19
  • 8

1 Answers1

0

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

Tom Barron
  • 1,554
  • 18
  • 23