Stupid windows fork

runrig on 2006-10-06T17:02:16

After looking at Abigail's post I wanted to write a stupid test program to attempt to confirm my assumptions, and started with this:

my $pid = open(my $fh, "yes|") or die "Acck: $!";
my $i;
while (<$fh>) {
  print;
  last if ++$i > 10;
}
print "Closing\n";
close $fh or die "Acck: $!";
print "Done!\n";
This works fine on Unix, and I have unix utilities installed on Windows, so I tried it there, and it gets hung up closing the file handle. If you ctrl-C out, 'yes' is left running in the shell, chewing up resources. I found out after running this a few times, and noticing that my PC was making "I'm working really hard" type noises. 'exit' at the cmd shell prompt gets hung up also, and the yes processes don't go away until you kill the shell window (by clicking the "please die" red X).