Replies: 7 comments 13 replies
-
没能复现,所有子进程默认都是在一个进程组的,按理不需要捕获,所有子进程都是会收到 ctrl+c 自动退出,只有父子进程不在一个进程组,才需要捕获,还得遍历整颗进程树去挨个 kill。。 目前只有主动正常退出时候,子子进程还无法正常跟随退出,暂时没法获取到整颗进程树,我只 kill 了单层。 $ xmake r -d
(lldb) target create "/private/tmp/xxxx/build/macosx/x86_64/debug/xxxx"
Current executable set to '/private/tmp/xxxx/build/macosx/x86_64/debug/xxxx' (x86_64).
(lldb)
Current executable set to '/private/tmp/xxxx/build/macosx/x86_64/debug/xxxx' (x86_64).
(lldb)
Current executable set to '/private/tmp/xxxx/build/macosx/x86_64/debug/xxxx' (x86_64).
(lldb) ^C
(lldb)
ruki:xxxx ruki$ ps aux | grep lldb
ruki 82953 0.0 0.0 4277640 764 s022 S+ 11:06下午 0:00.00 grep lldb
ruki:xxxx ruki$ |
Beta Was this translation helpful? Give feedback.
-
关于 ctrl-c 未关闭gdb,最极端的情况是,gdb 和 shell 互相争夺输入 |
Beta Was this translation helpful? Give feedback.
-
看了下,这似乎跟 xmake 也没啥关系,是 gdb 自己捕获 ctrl-c 屏蔽了,ctrl-c 压根退不出 gdb ,只有按 q 才能退出。。 纯 gdb 运行 ctrl-c 都是退不出的,仅仅显示了 Quit 字样而已。 而 但是 xmake 却被 ctrl-c 退出了,所以 gdb 当然就一直存在了。。 而 lldb 不会捕获 ctrl-c 屏蔽,所以我这可以完全退干净,没遇到问题。 这种,xmake 也改不了什么,也不是 xmake 的问题。 $ gdb
GNU gdb (Ubuntu 12.1-3ubuntu1) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) Quit
(gdb) q |
Beta Was this translation helpful? Give feedback.
-
估计要设置一个 cancel_handler 去 kill 才行,system() 里面会去 kill all,跟 ctrl-c 没啥关系。。
https://elixir.bootlin.com/uclibc-ng/v1.0.42/source/libc/stdlib/system.c |
Beta Was this translation helpful? Give feedback.
-
gdb 输出 quit,因为父进程退出了,gdb 有理由也退出进程(但是不知道为什么会存在延时) 解决方案分两步:
你可以试试 |
Beta Was this translation helpful? Give feedback.
-
父进程接收到 sigint 没有捕获,默认操作是退出进程,gdb 也会受到 sigint捕获了,但是他可以判断父进程时候存在,不存在就退出进程。 如果gdb 收到 sigint后能够及时判断父进程不存在那应该及时退出。 代码片段已经给你了,为什么不试试。我反正测试过了
|
Beta Was this translation helpful? Give feedback.
-
十分抱歉,是我的描述错误。
知识点不足导致严重的描述错误。 我不是想在收到到sigint 后信号杀死gdb。 而是想收到 sigint 信号后xmake任然存在,方便调试。 十分抱歉😵 |
Beta Was this translation helpful? Give feedback.
-
xmake r -d
当程序运行时,能够捕获 ctrl-c 使程序中断,但是此时再次 CTRL-C 时 xmake 会退出。
并且子进程 gdb 会变成独立进程而存在(尽管在shell只输入几次回车后会退出)。
能否捕获 ctrl-c 传递给子进程?
Beta Was this translation helpful? Give feedback.
All reactions