tags:

views:

99

answers:

1

Hello world.

I'm kind of new to unix environment.

I want to have a little chat program that the initial terminal is used for input, and invoke

another terminal for output.

I've been searching the web but without any luck.

Hope I can get some clues here.

Thanks.

Ok, to be more specific, I am writing a chat program over tcp/ip on mac in c.

I want to seperate the input and chatting messages output in two different terminals.

I can find resources on how to communicate between processes, but I don't know how to

invoke another terminal for the output.

A: 

It is rather unusual to spawn another terminal the way you seem to be doing. A cleaner approach would be to use a file (or a named pipe) to receive the output from your chat program, then run tail -f (or another program to properly format the output) on another terminal to display it's contents. The first terminal would be used for input (possibly from stdin), and the second terminal would receive the output of tail.

A sample command-line usage would be:

  1. Run the chat client, sending any output to a file named "output":

    $ ./client [parameters] > output
    
  2. In another terminal, display the output by reading from this file:

    $ tail -f output
    

Remember that your chat program should be able to handle two different sources of input simultaneously (incoming messages both from the server and from the user), probably using select().

Alek
This seems like a feasible solution. Thanks
shawn