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

warning not emmited when reading/writing to '-' and STDIN/STDOUT is being closed #5243

Open
p5pRT opened this issue Mar 11, 2002 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 11, 2002

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

Searchable as RT8825$

@p5pRT
Copy link
Author

p5pRT commented Mar 11, 2002

From tagunov@motor.ru

This is a bug report for perl from "Anton Tagunov" <tagunov@​motor.ru>
generated with the help of perlbug 1.33 running under perl v5.7.3.


Hello, developers!

use strict; use warnings;
open STDIN, 'echo a|';
open FH, '-';
my $w;
close STDIN;
#close FH;
$SIG{__WARN__}=sub{$w=shift};
my $v=<FH>;
print "not " unless $w;
print "ok 1\n";
open(my $oldout, ">&STDOUT");
open FH,'>-';
undef $w;
close STDOUT;
#close FH;
print FH 'bogus';
print $oldout "not " unless $w;
print $oldout "ok 2\n";

If you uncomment the close FH; lines the test will print only
"ok"-s.

I believe that this script should either be made printing "not ok"
even if we uncomment close FH; lines or be made print "ok"-s if
it runs as it is.

Possibly related to [ID 20020306.016] win NT​: when close '<&='
file handle the original one remains open...

Best regards - Anton



Flags​:
  category=core
  severity=low


Site configuration information for perl v5.7.3​:

Configured by anthony at Mon Mar 11 18​:43​:11 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​:\perl15173\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​:\perl15173\lib\CORE" -machine​:x86'

Locally applied patches​:
  DEVEL15172


@​INC for perl v5.7.3​:
  c​:/perl15173/lib
  c​:/perl15173/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\ds40\SharedIDE\BIN;e​:\apps\ds40\VC\BIN;e​:\apps\ds40\VC\BIN\WINNT;E​:\apps\ibm\vaj\eab\bin;C​:\usr\local\bin\;e​:\Program Files\ibm\gsk5\lib;E​:\APPS\ROSE\RATION1\NUTCROOT\bin;E​:\APPS\ROSE\RATION1\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;G​:\MSVC50\VC\BIN;G​:\MSVC50\VC\BIN\WINNT
  PERL_BADLANG (unset)
  SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Jun 16, 2011

From @chorny

Still no warnings/errors on 5.14.0. Also it is not possible to do "close
STDIN;" in this case, error is "Bad file descriptor".

Meaning of this bug report​: if you read from closed filehandle, a
warning is printed. If it is a copy (not dupe) of this filehandle and
original filehandle is closed, no warning is printed. Choosing something
other than STDIN and using &= gives same results.

On Mon Mar 11 03​:17​:35 2002, tagunov@​motor.ru wrote​:

use strict; use warnings;
open STDIN, 'echo a|';
open FH, '-';
my $w;
close STDIN;
#close FH;
$SIG{__WARN__}=sub{$w=shift};
my $v=<FH>;
print "not " unless $w;
print "ok 1\n";
open(my $oldout, ">&STDOUT");
open FH,'>-';
undef $w;
close STDOUT;
#close FH;
print FH 'bogus';
print $oldout "not " unless $w;
print $oldout "ok 2\n";

If you uncomment the close FH; lines the test will print only
"ok"-s.

I believe that this script should either be made printing "not ok"
even if we uncomment close FH; lines or be made print "ok"-s if
it runs as it is.

--
Alexandr Ciornii, http​://chorny.net

@p5pRT

This comment has been minimized.

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

2 participants