tags:

views:

86

answers:

3

I have an application which spawns several processes. Is it possible to redirect the output of the children to another hidden terminal so that it does not mix with the parent output and give the ability to the end user to unhide the terminal when needed?

Thanks.

+1  A: 

The quick and dirty way to do this is to redirect the child process' output to a (temporary) file.

A terminal tracking that file can then be started using a command like

xterm -e tail -f /tmp/child1.out

This terminal can be closed and opened when needed.

If you'd rather not store the output in a file, you can use a fifo (see mkfifo(1)), but then you lose the ability to see the past output, since a fifo doesn't store data.

Michiel Buddingh'
I thought about pumping the output into a FIFO the question is if nobody is reading from the FIFO and my application is running for weeks won't it fill the OS's RAM with this needless output?
Jack
Nope. It will block you program. :-)
Thomas
Are there any restrictions on how much a process can write into a pipe before the reader will start emptying it?
Jack
Yes. For your purposes you can't use a FIFO unless you intend to have the reader running all the time. If you are serious about writing for weeks w/o a reader than a regular file (probably with some kind of rotation after reaching a certain size) is the only real choice.
Duck
A: 

from your terminal, run:

touch proc1.log
xterm -e tail -f proc1.log
topuch proc2.log
xterm -e tail -f proc2.log
/run/proc/1.sh >> proc1.log
/run/proc/2.sh >> proc2.log

now you have 2 terminals following the output of the spawned processes

dsm
A: 

Screen can do this. You can start a detached screen with the new program.

Something like:

screen -d -m -S my-emacs-session emacs foo.c
Thomas