Skip Menu |
 
Report information
Id: 23838
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: dcd <david.dyck [at] fluke.com>
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: medium
Type: core
Perl Version: 5.9.0
Fixed In: (no value)



Date: Thu, 18 Sep 2003 11:10:24 -0700
From: David Dyck <dcd [...] tc.fluke.com>
To: perlbug [...] perl.org
Subject: incorrect warning: Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line 123
Download (untitled) / with headers
text/plain 3.2k
This is a bug report for perl from david.dyck@fluke.com, generated with the help of perlbug 1.34 running under perl v5.9.0. ----------------------------------------------------------------- [Please enter your report here] When doing a make test in CGI::Minimal from CPAN, perl issued the following warning 222 times. Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line As you can see line 123 doesn't reference STDIN, so this warning seems incorrect 122 my $test_file = "test-data.$$.data"; 123 open (TESTFILE,">$test_file") || return ("failed : could not ope [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=medium --- Site configuration information for perl v5.9.0: Configured by dcd at Wed Sep 17 05:06:38 PDT 2003. Summary of my perl5 (revision 5.0 version 9 subversion 0 patch 21261) configuration: Platform: osname=linux, osvers=2.4.23pre1, archname=i686-linux uname='linux dd 2.4.23pre1 #2 wed aug 27 11:20:37 pdt 2003 i686 ' config_args='-Dmksymlinks -Dinstallusrbinperl -Uversiononly -Dusedevel -Doptimize=-O3 -g -de -Dcf_email=david.dyck@fluke.com' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O3 -g', cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='egcs-2.91.66.1 19990314/Linux (egcs-1.1.2 release)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -ldbm -ldb -ldl -lm -lc perllibs=-ldl -lm -lc libc=/lib/libc.so.5.4.44, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Locally applied patches: DEVEL20173 --- @INC for perl v5.9.0: /usr/local/lib/perl5/5.9.0/i686-linux /usr/local/lib/perl5/5.9.0 /usr/local/lib/perl5/site_perl/5.9.0/i686-linux /usr/local/lib/perl5/site_perl/5.9.0 /usr/local/lib/perl5/site_perl/5.8.0/i686-linux /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl . --- Environment for perl v5.9.0: HOME=/home/dcd LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/dcd/bin:/sbin:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/games:/usr/local/samba:/home/hobbes/tools/scripts:/home/hobbes/tools/linux:/usr0/hobbes/tools/scripts:/usr0/dcd/bin:/apps/general/bin:/usr/public PERL5_CPANPLUS_CONFIG=/home/dcd/.cpanplus/config PERL_BADLANG (unset) SHELL=/bin/bash
Date: Thu, 18 Sep 2003 23:24:43 +0100
From: Dave Mitchell <davem [...] fdgroup.com>
To: perl5-porters [...] perl.org
Subject: Re: [perl #23838] incorrect warning: Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line 123
RT-Send-Cc:
Download (untitled) / with headers
text/plain 979b
On Thu, Sep 18, 2003 at 06:11:14PM -0000, David Dyck wrote: Show quoted text
> When doing a make test in CGI::Minimal from CPAN, > perl issued the following warning 222 times. > > Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line > > As you can see line 123 doesn't reference STDIN, so this warning seems > incorrect > > 122 my $test_file = "test-data.$$.data"; > 123 open (TESTFILE,">$test_file") || return ("failed : could not ope
I'm presuming that sometime earlier the test script closed STDIN, which was file descriptor 0. When $testfile is opened for writing, UNIX assigns to it the lowest unused file descriptor, which happens to be be 0. So STDIN is now open agian, but only for writing. In this case, I think it's probably good that Perl is warning you of this fact. -- print+qq&$}$"$/$s$,$*${$}$g$s$@$.$q$,$:$.$q$^$,$@$*$~$;$.$q$m&if+map{m,^\d{0\,},,${$::{$'}}=chr($"+=$&||1)}q&10m22,42}6:17*2~2.3@3;^2$g3q/s"&=~m*\d\*.*g
Date: Fri, 19 Sep 2003 00:34:14 +0200
From: Rafael Garcia-Suarez <rgarciasuarez [...] free.fr>
To: perl5-porters [...] perl.org
CC: SNOWHARE [...] cpan.org
Subject: Re: [perl #23838] incorrect warning: Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line 123
RT-Send-Cc:
Download (untitled) / with headers
text/plain 817b
David Dyck (via RT) wrote: Show quoted text
> When doing a make test in CGI::Minimal from CPAN, > perl issued the following warning 222 times. > > Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line > > As you can see line 123 doesn't reference STDIN, so this warning seems > incorrect > > 122 my $test_file = "test-data.$$.data"; > 123 open (TESTFILE,">$test_file") || return ("failed : could not ope
I see that the test closes STDIN. http://search.cpan.org/src/SNOWHARE/CGI-Minimal-1.10/t/01_decode_form.t The next open will reuse the lowest file descriptor available, which will be the one of stdin (0). The warning just warns you that you're using fd #0 for output, which is uncommon. The test needs to be fixed, e.g. by adding the appropriate "no warnings" clause.
Date: Thu, 18 Sep 2003 17:02:32 -0700 (PDT)
From: David Dyck <david.dyck [...] fluke.com>
To: Rafael Garcia-Suarez <perlbug-followup [...] perl.org>
Subject: Re: [perl #23838] incorrect warning: Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line 123
RT-Send-Cc:
On Thu, 18 Sep 2003 at 22:32 -0000, Rafael Garcia-Suarez <perlbug-followup@...: Show quoted text
> David Dyck (via RT) wrote:
> > When doing a make test in CGI::Minimal from CPAN, > > perl issued the following warning 222 times. > > > > Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line > > > > As you can see line 123 doesn't reference STDIN, so this warning seems > > incorrect > > > > 122 my $test_file = "test-data.$$.data"; > > 123 open (TESTFILE,">$test_file") || return ("failed : could not ope
> > I see that the test closes STDIN. > http://search.cpan.org/src/SNOWHARE/CGI-Minimal-1.10/t/01_decode_form.t > > The next open will reuse the lowest file descriptor available, which > will be the one of stdin (0). The warning just warns you that you're > using fd #0 for output, which is uncommon. > > The test needs to be fixed, e.g. by adding the appropriate "no warnings" > clause.
Thank you for responding to this. I see now that perldiag.pod states: Filehandle STDIN reopened as %s only for output (W io) You opened for writing a filehandle that got the same filehandle id as STDIN. This occured because you closed STDIN previously. In this case, (where the test script is control), the author could choose to do this, but it seems that you are suggesting that every sharable perl module that opens files for output needs to disable warnings on their open for output calls, just in case the perl application may have closed STDIN. I guess that there must be quite a reason for this, but it seems a bit strong to me. When I look through the scripts I have most of the close STDIN calls are in test code, and I can see how one wouldn't expect STDIN to be an output only file, but I guess what is bothering me is that the open call wasn't trying to do anyting with STDIN. open (TESTFILE,">$test_file") perhaps the rule to learn is that if someone closes STDIN they should re-open it as an input file soon after, or the will risk getting this message. Thanks again, David
To: david.dyck [...] fluke.com
Subject: Re: [perl #23838] incorrect warning: Filehandle STDIN reopened as TESTFILE only for output at t/ 01_decode_form.t line 123
CC: Rafael Garcia-Suarez <perlbug-followup [...] perl.org>
Date: Fri, 19 Sep 2003 08:14:41 +0100
From: Nick Ing-Simmons <nick.ing-simmons [...] elixent.com>
RT-Send-Cc:
Download (untitled) / with headers
text/plain 297b
David Dyck <david.dyck@fluke.com> writes: Show quoted text
>perhaps the rule to learn is that if someone closes STDIN >they should re-open it as an input file soon after, or >the will risk getting this message.
Yes. IMHO don't close STDIN and leave it closed re-open /dev/null or tmpfile or something...


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org