Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.98k stars 560 forks source link

win NT: when close '<&='-d file handle the original one remains open, pecularities of open FH, '-' #5226

Open p5pRT opened 22 years ago

p5pRT commented 22 years ago

Migrated from rt.perl.org#8805 (status was 'open')

Searchable as RT8805$

p5pRT commented 22 years ago

From tagunov@motor.ru

This is a bug report for perl from "Anton Tagunov" \tagunov@&#8203;motor\.ru\, generated with the help of perlbug 1.33 running under perl v5.7.3.


Hello!

1) Both of the following examples print their source :-(

use strict; use warnings; open FH\, $0 || die "$!"; open GH\, "\<&=FH"; close GH; while(\){print}

use strict; use warnings; open FH\, $0 || die "$!"; open GH\, "\<&=FH"; close FH; while(\){print}

That is \<&= behaves like \<&.

2) BTW\, open FH\, '-' behaves neither   like '\<&=STDIN' nor like '\<=' should behave​:

open STDIN\,'\<'.$0; open V\,'-'; close V; while(\){print}; #prints the source

open STDIN\,'\<'.$0; open V\,'-'; close STDIN; while(\){print}; #does not

3) Is this it like expected? Is it documented   anywhere? Where should this be documented   if it is not documented?

4) I have found no tests for this. Are there any?

Regards\, Anton



Flags​:   category=core   severity=medium


Site configuration information for perl v5.7.3​:

Configured by anthony at Wed Mar 6 00​:02​:07 2002.

Summary of my perl5 (revision 5 undef) configuration​:   Platform​:   osname=MSWin32\, osvers=4.0\, archname=MSWin32-x86-multi-thread   uname=''   config_args='undef'   hint=recommended\, useposix=true\, d_sigaction=undef   usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define   useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef   use64bitint=undef use64bitall=undef uselongdouble=undef   usemymalloc=n\, bincompat5005=undef   Compiler​:   cc='cl'\, ccflags ='-nologo -Gf -W3 -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX'\,   optimize='-O1 -MD -DNDEBUG'\,   cppflags='-DWIN32'   ccversion='undef'\, gccversion=''\, gccosandvers='undef'   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234   d_longlong=undef\, longlongsize=8\, d_longdbl=define\, longdblsize=10   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=4   alignbytes=8\, prototype=define   Linker and Libraries​:   ld='link'\, ldflags ='-nologo -nodefaultlib -release -libpath​:"c​:\perl5047\lib\CORE" -machine​:x86'   libpth=e​:\apps\ds40\VC\lib   libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib   perllibs=undef   libc=msvcrt.lib\, so=dll\, useshrplib=yes\, libperl=perl57.lib   Dynamic Linking​:   dlsrc=dl_win32.xs\, dlext=dll\, d_dlsymun=undef\, ccdlflags=' '   cccdlflags=' '\, lddlflags='-dll -nologo -nodefaultlib -release -libpath​:"c​:\perl5047\lib\CORE" -machine​:x86'

Locally applied patches​:   DEVEL15046


@​INC for perl v5.7.3​:   c​:/perl15046/lib   c​:/perl15046/site/lib   .


Environment for perl v5.7.3​:   HOME=C​:\   LANG (unset)   LANGUAGE (unset)   LC_ALL=EN_US   LD_LIBRARY_PATH (unset)   LOGDIR (unset)   PATH=E​:\apps\ibm\vaj\eab\bin;C​:\usr\local\bin\;e​:\Program Files\ibm\gsk5\lib;E​:\APPS\ROSE\RATION~1\NUTCROOT\bin;E​:\APPS\ROSE\RATION~1\NUTCROOT\bin\x11;E​:\APPS\ROSE\RATION~1\NUTCROOT\mksnt;e​:\java\sun\java131\bin;e​:\apps\vbroker\jre\Bin;e​:\apps\vbroker\Bin;C​:\WINNT\system32;C​:\WINNT;c​:\util;E​:\apps\CacheSys\Bin;C​:\Program Files\rksupport;C​:\WINNT\ton\bin;E​:\apps\rose\common;E​:\apps\rose\Rational Test;E​:\apps\borland\delphi\Bin;E​:\apps\borland\delphi\Projects\Bpl;E​:\apps\ibm\IBM\IMNNQ;E​:\apps\ibm\db2p\BIN;E​:\apps\ibm\db2p\FUNCTION;E​:\apps\ibm\db2p\SAMPLES\REPL;E​:\apps\ibm\db2p\HELP;e​:\apps\ibm\websphere\bin   PERL_BADLANG (unset)   SHELL (unset)

p5pRT commented 22 years ago

From [Unknown Contact. See original ticket]

use strict; use warnings; open FH\, 'echo a|' or die "$!"; open GH\, "\<&=FH"; close GH; my $w; $SIG{__WARN__}=sub{ $w=shift; }; my $v=\; print "not " unless $w && !defined($v); print "ok\n";

- Anton