
Is it possible to redirect a Handle (say stdout) somewhere only within a running thread (started with forkIO) not touching the same handle for the main and other threads? I have a lot of code written with putStr(Ln) which was used in a program acting as a filter, i. e. stdout was redirected by the invoking shell. Now I want to run this code within a thread in other program, but output must go to a file (or a pipe, or anywhere else a file descriptor may be opened for). So fdToHandle is not good because I need to modify the `stdout' only for that thread, not to create a new Handle. Rewriting the code is not a convenient way (but will be done if nothing else helps) because then I will need to pass that handle around. Running that code in a separate executable is just a bit more convenient because I need to pass many parameters via command line (a thread inherits values of them), and therefore is also desired to be avioded. Functions in System.Process deal with external executables. Does there exist anything like runInteractiveProcess, but just forking a new process (the whole memory is copied, so everything will be inherited), but executes a particular function within the parent program? I'm afraid that if I just make a foreign call to `fork', the RTS may not understand this correctly. -- Dimitry Golubovsky Anywhere on the Web