如何从python启动交互式程序(如gdb)?

时间:2021-07-20 23:47:12

I am going to start up gdb from python.

我将从python启动gdb。

For example:

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

But the gdb is not invoked as I expected, the interaction with gdb is broken. I have also tried os.system(), but it still doesnt work. What might I be doing wrong?

但是没有像我预期的那样调用gdb,与gdb的交互被破坏了。我也尝试过os.system(),但它仍然无法正常工作。我可能做错了什么?

1 个解决方案

#1


I think you meant

我想你的意思

p = subprocess.Popen(...)

You probably need to wait for p to finish:

您可能需要等待p完成:

p.wait()

#1


I think you meant

我想你的意思

p = subprocess.Popen(...)

You probably need to wait for p to finish:

您可能需要等待p完成:

p.wait()