Re: c program running 2 terminal windows, how to specify in which to write?

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 04/29/04


Date: Wed, 28 Apr 2004 21:27:22 -0400

In article <381de918.0404281549.770e43ae@posting.google.com>,
 achraf123@hotmail.com (Achraf) wrote:

> Hi all,
>
> I have a c program under linux, while running, it opens a new terminal
> windows using a system call. I would like to display messages on both
> windows.
> But I can't find a way to specify the terminal window I want to write
> in.
>
> The program is for chat and I want to keep a terminal window to write
> incoming messages, and use the other one for operation like sending
> messages or viewing list of nicks in the room....
>
> To start the new window, i use the command:
> system("gnome-terminal");
> or
> popen("gnome_terminal", "w");
> but with no results!!!
>
> but I really can't see if there is some possible way to write to it,
> all my messages keep arriving in the original window.
>
> If there is any way you can help me, I will be very thankful,

Why are you using terminal windows? You should just use the X API, or
an X toolkit, to create windows that you can manipulate directly. When
you open a terminal window and don't specify a program to run in it, it
just runs a shell -- it's not a general purpose display mechanism.

Howeer, if gnome_terminal is like xterm, it probably accepts a -S option
to let you specify a pty to send/receive its input/output. You would
first open a pty for each terminal window, and then provide this option
when running gnome_terminal. To send output to a particular window, you
would write to the corresponding master end of the pty.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


Relevant Pages

  • Re: changing grub
    ... such as gedit you need to ... command on the start of the line, not the sudo command, ... down the Terminal window will not also shut down your gedit ...
    (Ubuntu)
  • Re: Solved Re: Cmd Line not wrapping in gnome terminal window
    ... I opened a new terminal window and it worked just fine! ... Well behaved programs should return the terminal to its original state, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Quick Look stopped working
    ... Enter this into a terminal window to read about it: ... man qlmanage ... The error message has been ongoing every few minutes (preceded by either ...
    (comp.sys.mac.system)
  • Re: Client Connection Manager in Windows Server 2003?
    ... The application, running in a separate window, is the only thing ... MCSE, CCEA, Microsoft MVP - Terminal Server ... I used Client Connection manager to ... terminal window, only the AutoCAD application. ...
    (microsoft.public.windows.terminal_services)
  • Re: [kde-linux] where is kcontrol
    ... kde tends to be very noisy on STDOUT/STDERR. ... Another solution is to use the shell redirect functionality. ... It's not really designed to run from a terminal window unless you're ...
    (KDE)