How to attach an xterm to a process/thread ?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to attach an xterm to a process/thread ?
# 1  
Old 02-16-2008
Question 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 ?
# 2  
Old 02-17-2008
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...
# 3  
Old 02-23-2008
Question

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 Smilie
Quote:
-Sccn This option allows xterm to be used as an input and output
channel for an existing program and is sometimes used in spe-
cialized applications. The option value specifies the last
few letters of the name of a pseudo-terminal to use in slave
mode, plus the number of the inherited file descriptor. If
the option contains a "/" character, that delimits the char-
acters used for the pseudo-terminal name from the file
descriptor. Otherwise, exactly two characters are used from
the option for the pseudo-terminal name, the remainder is the
file descriptor. Examples:
-S123/45
-Sab34
Happened to find somebody else fiddling with that option here ...
/lib's Weblog
# 4  
Old 02-25-2008
Hammer & Screwdriver

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.
# 5  
Old 05-07-2009
can anybody explain the procedure more in depth? the link above is down. hope sombody can help me.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Attach process with port 2222

Hi Team, is there any way, I can start any process for e.g. run a shell script (infinite loop) and attach it to port 2222? I am trying to create a scenario where an application will start running at port 2222 and I will telnet the same to confirm, application port is listening. So,... (1 Reply)
Discussion started by: vivekpandit7
1 Replies

2. Shell Programming and Scripting

Get the process/thread running on which core

I use top -H -p 1256 to show process 1256, and then press "f" then press "j" to display it is running on which core, is there a better mothed, I want to be automated to get this (1 Reply)
Discussion started by: yanglei_fage
1 Replies

3. Programming

dbx - attach to process, break when crash

Hey everyone, I have a process that is crashing, and I'd like to have some way to see where it crashes. Is this possible? (2 Replies)
Discussion started by: ctote
2 Replies

4. UNIX for Dummies Questions & Answers

Thread count for a process id

Hi, I want to know a command/program to get thread count for a process id in unix box. Please help me in this regard. (1 Reply)
Discussion started by: manaac
1 Replies

5. UNIX for Dummies Questions & Answers

process and thread

i want to know a difference between process and thread,give a program to tell the difference (2 Replies)
Discussion started by: annapurna konga
2 Replies

6. Programming

Need the PID of a process in a thread

How do I run a process from a C++ p_thread and obtain its PID? Right now I am doing in a p_thread: system("ampl method.run"); and into the main function (after running the thread mentioned before): sleep(5); //Just to be sure that the thread is executing the ampl command system("ps... (1 Reply)
Discussion started by: riccollado
1 Replies

7. UNIX for Advanced & Expert Users

attach process from another ssh session

Hi, I was logged in on a server, by ssh, with a vim open, when the battery of my laptop got empty. When I return to the server by ssh, I can see my previous ssh session still open, and the vim process running (ttyp0). Is there a way to attach that vim to my new session (ttyp4)? Here's part... (2 Replies)
Discussion started by: raphinou
2 Replies

8. Shell Programming and Scripting

[BASH] xclock/xcalc/xterm...process question?

I have no idea how to do this: Let's say the user opens an "xclock &" in one of my scripts and I don't want him to be able to re-open one with the script. How could I test that? Possibly with a message saying that "The <xclock(or w/e other process like xcalc)> is already running in the... (3 Replies)
Discussion started by: Yakuzan
3 Replies

9. Shell Programming and Scripting

get Thread information from process

Hello all im trying to build small script in tcsh that will monitor some process that are making some api calles to some server . first of all im trying to find way to see how many threads each process is using , and else how can i print each Thread id . can it be done ? ( using sunOs ) (2 Replies)
Discussion started by: umen
2 Replies

10. Programming

List of Thread IDs of a process

Hello, Can some one tell how to read the thread IDs of the current process in Sun Solaris. Any help will be appreciated. regards, Murali (0 Replies)
Discussion started by: hmurali
0 Replies
Login or Register to Ask a Question