I came up with a minimal example of the fork writing to it's own xterm. It's kindof weird, trying get the ppid and pid, but this worked on linux. (At least it shows the concept). A second delay is needed to get the pids to showup properly.
#!/usr/bin/perl
use warnings;
use strict;
use Proc::ProcessTable;
my $time = time();
my $pid;
my $pid1 = open(PH,"| xterm -T $time -e bash");
print "pidinit $pid1\n";
sleep 1;
for my $p (@{new Proc::ProcessTable->table}){
if($p->ppid == $pid1){
$pid = $p->pid;
}
}
print "$pid\n";
open(FH,">/proc/$pid/fd/1") or warn $!;
for(1..1000){print STDOUT $_,"\n"; print FH $_.'a',"\n";sleep 1;}
close FH;
|