force coredump from child created by subprocess

David Sveningsson ext at sidvind.com
Tue Oct 5 14:45:54 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/05/2010 02:37 PM, Christian Heimes wrote:
> 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
> 

Thanks, it works perfect if I run in in preexec_fn.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyrHgIACgkQ6pa1H/H5pqWUzwCeNWW6CAjdjir40NXMJyMh8k7F
zeEAoKa9A5jdBd4CI6UTmUDKeD+QAPvO
=WZOy
-----END PGP SIGNATURE-----



More information about the Python-list mailing list