Posts

Showing posts with the label console

Realize a console in a GTK3 GUI programming in C

Realize a console in a GTK3 GUI programming in C I realized a GUI with GTK3 that, essentially, generates an input text file for an exe program that with these inputs can do elaborations. This exe is put in executions in the GUI by mean of a System call ( system("exe input.dat &") ). This exe can print on screen message of information or error. What I want to do is redirect these message on a GtkTextView. The idea that I had is to redirect output and error on a file ( system("exe input.dat > output_file.txt 2>&1 &") ) and in the GUI read line by line this file and send this strings in the textView. I was not sure that 2 process can write and read the same file and to test this concept I used these 2 simple programs: the writer (used like ./writer > out_file.txt): #include <stdio.h> #include <unistd.h> main() { int a; while(1) { fprintf(stdout,"a=%dn",a); ...