develooper Front page | perl.perl5.porters | Postings from March 2000

[ID 20000301.006] I/O problem with IO::Handle

Thread Next
From:
Raphael Manfredi
Date:
March 1, 2000 06:04
Subject:
[ID 20000301.006] I/O problem with IO::Handle
Message ID:
200003011403.PAA12367@lod28.gnb.st.com
This is a bug report for perl from raphael.manfredi@st.com,
generated with the help of perlbug 1.26 running under perl 5.00503.

-----------------------------------------------------------------
I don't understand what's happening here:

     1	use IO::Handle;
     2	use File::stat;
     3	
     4	open(STDERR, ">bug.stderr");
     5	
     6	$fn = fileno(\*main::STDERR);
     7	print "stderr at fd = #$fn\n";
     8	
     9	$h = IO::Handle->new_from_fd(\*main::STDERR, "w");
    10	print $h "to stderr?\n";
    11	$h->print("to stderr again?\n");
    12	
    13	close STDERR;
    14	
    15	my $st = stat("bug.stderr");
    16	printf "size = %d\n", $st->size;
    17	
    18	open(FILE, "bug.stderr");
    19	while (<FILE>) {
    20		print;
    21	}
    22	

When run, this produces:

	stderr at fd = #2
	size = 0

If I now "cat bug.stderr", I get:

	to stderr?
	to stderr again?

which is correct.

It's not a File::stat bug, because if I move the test on line 15
before line 4, I get the correct answer 28.
-----------------------------------------------------------------

---
Site configuration information for perl 5.00503:

Configured by manfredi at Mon Aug  9 12:37:05 MET DST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=solaris, osvers=2.5.1, archname=sun4-solaris
    uname='sunos lod23 5.5.1 generic_103640-27 sun4u sparc sunw,ultra-60 '
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef useperlio=define d_sfio=undef
  Compiler:
    cc='/apa/SUNWspro/bin/cc', optimize='-O', gccversion=
    cppflags='-I/home/manfredi/usr/BerkeleyDB/include'
    ccflags ='-I/home/manfredi/usr/BerkeleyDB/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=true
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='/apa/SUNWspro/bin/cc', ldflags ='-L/home/manfredi/usr/BerkeleyDB/lib'
    libpth=/lib /usr/lib /usr/ccs/lib /home/manfredi/usr/BerkeleyDB/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G -L/home/manfredi/usr/BerkeleyDB/lib'

Locally applied patches:
    

---
@INC for perl 5.00503:
    /home/manfredi/usr/lib/perl
    /home/manfredi/usr/lib/perl5/5.00503/sun4-solaris
    /home/manfredi/usr/lib/perl5/5.00503
    /home/manfredi/usr/lib/perl5/site_perl/5.005/sun4-solaris
    /home/manfredi/usr/lib/perl5/site_perl/5.005
    .

---
Environment for perl 5.00503:
    HOME=/home/manfredi
    LANG=fr
    LANGUAGE (unset)
    LC_MESSAGES=C
    LC_MONETARY=C
    LC_NUMERIC=C
    LC_TIME=C
    LD_LIBRARY_PATH=/home/manfredi/usr/lib/X11:/usr/openwin/lib
    LOGDIR (unset)
    PATH=/home/manfredi/bin/scripts:/home/manfredi/bin/sun:/home/manfredi/bin/sun/mh:/home/manfredi/bin/scripts/mh:/home/manfredi/bin/sun/fm2html:/home/manfredi/bin/scripts/rdb:/apa/gnu/SunOS5/bin:/bin:/usr/bin:/sbin:/usr/sbin:/apa/SUNWspro/bin:/usr/ccs/bin:/usr/ucb:/usr/contrib/bin:/apa/comp/SunOS5/bin:/apa/acroread/3.02/bin:/apa/ddts/bin:/apa/util/bin:/etc:/usr/bin/X11:/usr/games:/home/bruel/local/SunOS5/bin:/home/manfredi:.:/home/manfredi/bin/acri
    PERL_BADLANG (unset)
    SHELL=/home/manfredi/bin/sun/ksh

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About