I am porting some app from Windows to Linux. By default is has no window, but could open one for debug output. I need to do something similar on Linux. I found that XTerm could be used from it, however without any details how to do this.
This new window must be open by app itself, so starting app inside XTerm is not an option for me.
How to do this in C/C++ on CentOS 7?
Most of the terminal programs close their standard input/output/error, so you cannot simply pipe output to the terminal. xterm has an option -S
which lets you connect its I/O to a pseudo-terminal, which acts as an intermediate device through which you can communicate with the terminal.
There are a few applications which use this, which you could study to understand how this works. One (multixterm
) relies upon a toolkit which usually is not prepackaged. Another is a test-program ditto
, provided with ncurses. Debian and its derived distributions provide that in the ncurses-examples
package (but reading the source-code is the way to go). There aren't any useful tutorials on the topic (read the related manual pages).
You may have in mind something like this picture of the details screen from an installer:
however, examining the list of processes which are running shows that it is using the output of apt
either via a pipe (or pseudoterminal), redirected to a GUI window. The only way to know would be to read the source-code.