On Mon, Nov 03, 2003 at 07:14:48PM +0530, Akhilesh Suresh Shirbhate wrote:
The second solution is worthwhile only before I start
the program. But
what I need to do is readjust streams at runtime. For eg., suppose a
program is running and I see some interesting output on some screen. I
want to redirect it to a file now... How do I do that, without stopping
the process !
DISCLAIMER: I don't really know what your intention is. Moreover, I
have never done this, but I _think_ it could work ...
Basically, what you want to do is go and control the specific streams
attached to a running process. I don't know how to do that, but
there's another way, by building a wrapper around this program.
This wrapper could be a simple perl script or maybe a C program. It
should call the original program, and take control of its stderr and
stdout, and connect them to its own stderr and stdout in the default
state. Additionally, it should keep scanning for SIGNALs from you. Now
map different functions to different SIGNALs, which will redirect the
original programs strings to wherever you want ...
Sameer.
--
Research Scholar, KReSIT, IIT Bombay
http://www.it.iitb.ac.in/~sameerds/