Here is a piece of code that I have tried to
reproduce my problems. What is not in the code is that
I have some XS that is also spitting to stdout, so select $fh
will not give me what I must have.
#!/usr/local/bin/perl5.005 -w
use strict;
&a;
print "this goes to a\n";
close STDOUT;
close TEE;
&b;
print "this goes to b\n";
close STDOUT;
close TEE;
&c;
print "this goes to c\n";
close STDOUT;
close TEE;
&d;
print "this goes to d\n";
close STDOUT;
close TEE;
# this prints only "this goes to a" to stdout
# all other lines get printed to file, twice.
# if I remove the close STDOUT it hangs at the first close TEE
# if I remove all close statements and let the systems
# close TEE automatically because it is being used again
# I get a lockup on &b. I'm guessing it is where the system
# is trying to close the already open TEE
#So how do I open STDOUT after it has been closed?
# do I get the tty and open it to that?
# is there some other way to reopen STDOUT?
# the end must be that a copy of each line
# gets printed to screen and to file. I have
# to maintian the files for proof of execution
# for ??(days,weeks,months,years) to come.
# what my options are NOT:
# 1. Rewriting my c library in perl
# 2. Splitting up ALL subroutines into programs
# so that `prog 2>1&` or whatever will work
# 3. Just forgetting about.
# Is there a c subroutine that I can get that will
# do the above? if someone knows of such critter
# I'll make a module of it.
sub a
{
open TEE , "|tee a.out";
open STDOUT , ">&TEE";
}
sub b
{
open TEE , "|tee b.out";
open STDOUT , ">&TEE";
}
sub c
{
open TEE , "|tee c.out";
open STDOUT , ">&TEE";
}
sub d
{
open TEE , "|tee d.out";
open STDOUT , ">&TEE";
}
========+=========+=========+=========+=========+=========+=========+
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methology Group
Dallas, Texas
214-480-4455
[EMAIL PROTECTED]
=========+=========+=========+=========+=========+=========+=========+