Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect warning: Filehandle STDIN reopened as TESTFILE only for output at t/01_decode_form.t line 123 #6770

Closed
p5pRT opened this issue Sep 18, 2003 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 18, 2003

Migrated from rt.perl.org#23838 (status was 'resolved')

Searchable as RT23838$

@p5pRT
Copy link
Author

p5pRT commented Sep 18, 2003

From david.dyck@fluke.com

Created by david.dyck@fluke.com

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

Perl Info

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

@p5pRT
Copy link
Author

p5pRT commented Sep 18, 2003

From @iabyn

On Thu, Sep 18, 2003 at 06​:11​:14PM -0000, David Dyck 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'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*22.3@​3;^2$g3q/s"&=~m*\d\*.*g

@p5pRT
Copy link
Author

p5pRT commented Sep 18, 2003

From @rgs

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.

@p5pRT
Copy link
Author

p5pRT commented Sep 19, 2003

From david.dyck@fluke.com

On Thu, 18 Sep 2003 at 22​:32 -0000, Rafael Garcia-Suarez <perlbug-followup@​...​:

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

@p5pRT
Copy link
Author

p5pRT commented Sep 19, 2003

From nick.ing-simmons@elixent.com

David Dyck <david.dyck@​fluke.com> writes​:

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...

@p5pRT p5pRT closed this as completed Sep 21, 2003
@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2003

@rgs - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant