如何在Python中启动交互式程序(如gdb)?

1 投票
1 回答
571 浏览
提问于 2025-04-15 11:45

我打算从Python启动gdb这个调试工具。

比如说:

prog.shell.py:
    #do lots of things
    #
    #
    p.subprocess.Popen("gdb --args myprog", shell=True, stdin=sys.stdin, stdout=sys.stdout)

但是gdb没有像我预期的那样被启动,和gdb的互动也出现了问题。我也试过os.system(),但还是不行。我可能哪里做错了呢?

1 个回答

3

我想你是想说

p = subprocess.Popen(...)

你可能需要等 p 完成后再继续:

p.wait()

撰写回答