How to attach an xterm to a process/thread ?

Hi folks,

I would like to know how to hook up an xterm to another process.

Here is a high level view of what I am looking for

  1. Main program starts
  2. It creates an new xterm window
  3. It then forks a second process & passes the xterm handle to it
  4. The second process uses the second xterm for input & output

A slightly different idea would be, one process making threads, and each thread has its own xterm. I don't know if this is possible because AFAIK, the standard file descriptors apply to the whole process an not individual threads.

I am afraid if the "xterm -e foo.exe" will work for me.
Any ideas ?
Can I use a pty just like a file ?

From your description, it's difficult to know if U program in C, XWindow, or scripting in Perl, ksh or dtksh... but maybe the easiest way is to use named pipes.

Simply creates your named pipes and read/write to them from any process or thread...

For example, main process creates 5 threads, each thread create his named pipe and write data to his named pipe, main process then creates 5 xterm process reading and printing each named pipes...

Also, if the data is not volatile, threads can write data to regular files and xterm processes could read them continuously like 'tail -f'...

We are limited just by our imagination... depending on the task to do, U can use shared memory, memory mapped files, message queues, database, indexed files, etc...

I am programming in C.

My idea is to use the
'xterm -Sccn' option.

Unfortunately I am not clear about what "Inherited file descriptor" means :confused:

Happened to find somebody else fiddling with that option here ...
/lib's Weblog

Well, I got it working.
We have to use the file descriptor returned by ptsname() for reading & writing.
and the xterm's -Sccn option holds good only when it is invoked from within a process with a system() call.

can anybody explain the procedure more in depth? the link above is down. hope sombody can help me.