0

Possible Duplicate:
How to invoke another terminal for output programmatically in C in Linux

I am programming a client-server application and I want to create a debug window.

On the server side I want to print the incoming and outgoing communication on a separate terminal. I am able to spawn a terminal through gnome-terminal but how to write on it and not on other terminals.

Community
  • 1
  • 1
Mohammad Umair Khan
  • 515
  • 2
  • 9
  • 24
  • http://stackoverflow.com/questions/3445645/how-to-invoke-another-terminal-for-output-programmatically-in-c-in-linux – ob_dev Dec 31 '11 at 08:26

3 Answers3

2

Unless you for some reason really need to print to a terminal, I wouldn't bother, not just for a debug printout.

I would have the server print to a log file (remembering to flush it appropriately often) and then use tail -f in another terminal to follow it. This has the added benefit of giving me a record of what the server debug-printed that I can examine at leisure.

ibid
  • 3,891
  • 22
  • 17
  • okay another idea, what if I spawn system("xterm") and redirect all STDERR_FILENO to the new xterm, ill be able to achieve what i want, but how do i map STDERR_FILENO to the new xterm? – Mohammad Umair Khan Dec 31 '11 at 08:49
  • @ibid you could also write to a named pipe instead of a file – fge Dec 31 '11 at 10:15
1

Combining idea of @ibid idea to what you want. Write to log file and than execute:

xterm -e tail "-f" log_file

This will span xterm , which executes "tai -f log file" command.

dimba
  • 26,717
  • 34
  • 141
  • 196
0

The "correct" answer to this question is that you can write to /dev/ttyNUM... if you know the right tty number.

But that's only technical correctness, you should do something else. What you're trying to do is wrong.

cha0site
  • 10,517
  • 3
  • 33
  • 51