I am pretty certain this proves there is a serious Unicode-processing bug going on, given that this output:
perl5.16.0 ungettest
ungettest 98896 @ Sun Jan 6 16:01:08 2013: sending normal line to kid
ungettest 98896 @ Sun Jan 6 16:01:08 2013: await()ing kid
ungettest 98897 @ Sun Jan 6 16:01:08 2013: ungetting litte z
ungettest 98897 @ Sun Jan 6 16:01:08 2013: ungetting big sigma
ungettest 98897 @ Sun Jan 6 16:01:08 2013: kid looping on parental input
98897: Unexpected fatalized warning: utf8 "\xA3" does not map to Unicode at ungettest line 40, <STDIN> line 1.
at ungettest line 10, <STDIN> line 1.
main::__ANON__('utf8 "\xA3" does not map to Unicode at ungettest line 40, <ST...') called at ungettest line 40
98896: parent pclose failed: 65280, at ungettest line 28.
Exit 255
is produced by this program:
#!/usr/bin/env perl
use v5.16;
use strict;
use warnings;
use open qw( :utf8 :std );
use Carp;
$SIG{__WARN__} = sub { confess "$$: Unexpected fatalized warning: @_" };
sub ungetchar($) {
my $char = shift();
confess "$$: expected single character pushback, not <$char>" if length($char) != 1;
STDIN->ungetc(ord $char);
}
sub debug {
my $now = localtime(time());
print STDERR "$0 $$ \@ $now: @_\n";
}
if (open(STDOUT, "|-") // confess "$$: cannot fork: $!") {
$| = 1;
debug("sending normal line to kid");
say "From \N{greek:alpha} to \N{greek:omega}.";
debug("await()ing kid");
close(STDOUT) || confess "$$: parent pclose failed: $?, $!";
debug("child finished, parent exiting normally");
exit(0);
}
debug("ungetting litte z");
ungetchar("z") || confess "$$: ASCII ungetchar failed: $!";
debug("ungetting big sigma");
ungetchar("\N{greek:Sigma}") || confess "$$: Unicode ungetchar failed: $!";
debug("kid looping on parental input");
while (<STDIN>) {
chomp;
debug("kid got $_");
}
close(STDIN) || confess "$$: child pclose failed: $?, $!";
debug("parent closed pipe, child exiting normally");
exit 0;