简体   繁体   English

如何使用c ++ / python程序在终端中运行程序,然后在该程序中执行语句

[英]how to run a program in terminal using c++/python program and then execute statements in that program

I want to create a GUI for GDB debugger, so I need a way to run GDB debugger in terminal and execute commands in that and also get output from that on user triggered events on my screen in ubuntu. 我想为GDB调试器创建一个GUI,因此我需要一种在终端中运行GDB调试器并在其中执行命令的方法,并从ubuntu屏幕上的用户触发事件中获取该输出。 how can I do that for such a program? 如何为这样的程序做呢?

it tried 它尝试了

int main(){
    system("gnome-terminal 'gdb  test'");
    system("break main");
    return 0;
}

but it executes the command on the terminal not on the gdb program 但是它在终端而不是gdb程序上执行命令

Each of the system() calls opens a separate shell. 每个system()调用都会打开一个单独的shell。 So these are independent of each other. 因此,它们彼此独立。

If you want to continuously communicate with a child process, rather use popen() please. 如果要与子进程持续通信,请使用popen()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM