【发布时间】:2016-10-19 09:44:27
【问题描述】:
我需要从我的 python 脚本启动一个外部程序。 这个程序崩溃了,所以我需要从中获取核心转储。
我能做什么?
【问题讨论】:
我需要从我的 python 脚本启动一个外部程序。 这个程序崩溃了,所以我需要从中获取核心转储。
我能做什么?
【问题讨论】:
查看 python resource 模块。它会让你设置核心文件的大小等,就像 ulimit 命令一样。具体来说,你想做类似的事情
resource.setrlimit(resource.RLIMIT_CORE, <size>)
在启动您的目标程序之前。
我对用法的猜测(我自己没有这样做过)是:
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
【讨论】: