force coredump from child created by subprocess

Christian Heimes lists at cheimes.de
Tue Oct 5 08:37:06 EDT 2010


Am 05.10.2010 14:15, schrieb David Sveningsson:
> Hi, I am running a process using subprocess and detect if the process
> crashes using .returncode. I would like to force coredumps being created
> regardless of the system settings, eg run "ulimit -c unlimited" in the
> childprocess.
> 
> I've had no luck using preexec_fn and os.system, it just made no
> difference. I could probably add a thin wrapper script but I'm not very
> fond of that idea.
> 
> Is there some easy way to force the childprocess to create a coredump if
> it crashes?

This code snippet enables core dumps for the current Python process. It
should also enable it for child processes.

import resource
resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))

Christian




More information about the Python-list mailing list