Bug#554945: Autoflushing of stdout is broken with perl 5.10
Roger Leigh
rleigh at debian.org
Sat Nov 7 12:19:11 UTC 2009
Package: perl
Version: 5.10.1-6
Severity: normal
This thread also describes the problem:
http://coding.derkeiler.com/Archive/Perl/comp.lang.perl.misc/2009-06/msg00035.html
In sbuild, we use the following routine to print log messages:
while (<STDIN>) {
if ($nolog) {
print $saved_stdout $_;
} else {
if ($log) {
print CPLOG $_;
}
if ($verbose) {
print $saved_stdout $_;
}
}
}
in a child logger process which reads from a pipe. Taken from the sub
open_build_log from
http://git.debian.org/?p=buildd-tools/sbuild.git;a=blob;f=lib/Sbuild/Build.pm;h=5c408976f20969823b619c770ba41c503541d86c;hb=HEAD
This is using standard buffered I/O on $saved_stdout, which is just a
dup'd reference to STDOUT.
if I add these changes:
@@ -2585,12 +2586,14 @@ sub open_build_log {
+ $saved_stdout->autoflush(1);
while (<STDIN>) {
if ($nolog) {
print $saved_stdout $_;
+ $saved_stdout->flush();
} else {
if ($log) {
print CPLOG $_;
}
if ($verbose) {
print $saved_stdout $_;
+ $saved_stdout->flush();
}
}
}
What I see is that if I just set autoflushing, the output is still
buffered. If I (additionally or separately) add the explicit
flushing after print, then I do see correct flushing.
The conclusion I've drawn is that autoflushing does not work on
stdout. The other handle, CPLOG, has set autoflushing without
any problems at all. The above thread from comp.lang.perl.misc
shows the same behaviour.
Regards,
Roger
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (550, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.31-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages perl depends on:
ii libbz2-1.0 1.0.5-3 high-quality block-sorting file co
ii libc6 2.10.1-5 GNU C Library: Shared libraries
ii libdb4.7 4.7.25-8 Berkeley v4.7 Database Libraries [
ii libgdbm3 1.8.3-7 GNU dbm database routines (runtime
ii perl-base 5.10.1-6 minimal Perl system
ii perl-modules 5.10.1-6 Core Perl modules
ii zlib1g 1:1.2.3.3.dfsg-15 compression library - runtime
Versions of packages perl recommends:
ii make 3.81-7 An utility for Directing compilati
ii netbase 4.37 Basic TCP/IP networking system
Versions of packages perl suggests:
pn libterm-readline-gnu-perl | l <none> (no description available)
ii perl-doc 5.10.1-6 Perl documentation
-- no debconf information
More information about the Perl-maintainers
mailing list