【问题标题】:How to check Ubuntu program coredump in either bash or python?如何在 bash 或 python 中检查 Ubuntu 程序 coredump?
【发布时间】:2016-08-31 20:20:42
【问题描述】:

我有一个二进制 foo,我会给 foo 一个文件输入,这可能会触发 Ubuntu 中的 coredump。我为此编写了一个循环,并在每次迭代中更改文件内容。但我想在出现 coredump 时终止循环。这是 bash 代码:

while true
do
  change_file file_s > file_new
  ./foo file_new
  # need to check coredump to terminate the loop
done

如果在 python 中更容易,我可以将脚本更改为 python。

【问题讨论】:

  • foo 是否会因为非核心转储原因返回非零值?

标签: python bash ubuntu coredump


【解决方案1】:

如果返回码大于 127,则程序因信号而退出。核心转储仅作为这种退出的结果发生。

./foo file_new
if (($? > 127)); then
    echo foo crashed
    break
fi

【讨论】:

    猜你喜欢
    • 2018-08-27
    • 2019-01-17
    • 2011-02-06
    • 2016-10-31
    • 2010-10-10
    相关资源
    最近更新 更多