python , launch an external program with ulimit
<p>I need to launch an external program from my python script. 
This program crashes, so I need to get a core dump from it.</p>

<p>what can i do?</p>

<p>Check out the python <a href="https://docs.python.org/2.7/library/resource.html?highlight=resource#module-resource" rel="nofollow">resource</a> module. It will let you set the size of core files, etc., just like the ulimit command. Specifically, you want to do something like</p>

<pre><code>resource.setrlimit(resource.RLIMIT_CORE, &lt;size&gt;)
</code></pre>

<p>before launching your target program.</p>

<p>My guess at usage (I haven't done this myself) is:</p>

<pre><code>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
</code></pre>

<hr>

python ulimit