kar09 kar09 - 4 months ago 14
Linux Question

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. 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

Answer

Each of the system() calls opens a separate shell. So these are independent of each other.

If you want to continuously communicate with a child process, rather use popen() please.