linux - 在脚本中运行 gdb 时自动退出

标签 linux bash

我尝试使用 gdb 调试一个由脚本创建的新进程。 在 linux shell 中,我试过这个:

ps -ef | grep -i [m]yprocess |  awk '{print "gdb -p "  $2}'  | sh

每次,gdb都会自动得到一个‘quit’然后退出:

***0xf7788430 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-105.i686 libgcc-4.8.3-10.i686
(gdb) quit
A debugging session is active.
    Inferior 1 [process 834] will be detached.
Quit anyway? (y or n) [answered Y; input not from terminal]***

我该怎么做才能解决这个问题?

最佳答案

你可以这样做

gdb -p `pgrep myprocess`

我猜奇怪的行为是由于 STDIN 不是终端而是 awk 的管道造成的。

关于linux - 在脚本中运行 gdb 时自动退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43423798/

相关文章:

linux - 为什么这个 shell 管道会退出?

c - 在 linux : differences between canonical and non-canonical methods 中写入 C 中的串行端口

python - 使用 bash 或 python 或其他一些 linux 命令行工具创建一个 dovecot SHA1 摘要

linux - SSH 权限错误

C:在处理大数时避免溢出

bash - 在 Bamboo 中通过 SSH 的 nohup 命令不会退出

linux - 用于复制文件、重命名并将其共享到 azure blob 的脚本

bash - 在 shell 脚本中使用 ssh 登录在服务器上创建 cron 条目

linux - 在linux中根据内容拆分文件

linux - 如何连接两个文件并将结果写回原始文件之一