It is very unusual to spawn another terminal, as you seem to be doing. A cleaner approach would be to use a file (or named pipe) to get output from your chat program, then run tail -f (or another program to format the output correctly) on another terminal to display its contents. The first terminal will be used for input (possibly from stdin ), and the second terminal will receive tail output.
Command line example:
Launch the chat client by sending any output to a file called "output":
$ ./client [parameters] > output
In another terminal, display the output by reading from this file:
$ tail -f output
Remember that your chat program should be able to simultaneously process two different input sources (incoming messages from both the server and the user), possibly using select() .
source share