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

STDIN inaccessable after undef'ing it #5687

Closed
p5pRT opened this issue Jun 28, 2002 · 5 comments
Closed

STDIN inaccessable after undef'ing it #5687

p5pRT opened this issue Jun 28, 2002 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 28, 2002

Migrated from rt.perl.org#10006 (status was 'abandoned')

Searchable as RT10006$

@p5pRT
Copy link
Author

p5pRT commented Jun 28, 2002

From d@niel-berlin.de

Created by fw8y079@public.uni-hamburg.de

# This works​:
#
open (FH, '</proc/meminfo') || die; # opens that file

print `ls -l /proc/$$/fd | grep -v total`; # output ok
undef *FH; # close _and_
undef FH
print `echo;ls -l /proc/$$/fd | grep -v total`; # output ok

#------------------------------

# This makes *STDIN inaccessable without closing it​:
#
undef *STDIN;
print `ls -l /proc/$$/fd | grep -v total`;

# Output #1
#lrwx------ 1 root root 64 Jun 28 17​:20 0 -> /dev/tty3
#lrwx------ 1 root root 64 Jun 28 17​:20 1 -> /dev/tty3
#lrwx------ 1 root root 64 Jun 28 17​:20 2 -> /dev/tty3
#lr-x------ 1 root root 64 Jun 28 17​:20 3 -> pipe​:[17052169]
#lr-x------ 1 root root 64 Jun 28 17​:20 5 -> pipe​:[17052170]

close (STDIN);
print `echo; ls -l /proc/$$/fd | grep -v total`;

# Output #2
#lrwx------ 1 root root 64 Jun 28 17​:20 0 -> /dev/tty3
#lrwx------ 1 root root 64 Jun 28 17​:20 1 -> /dev/tty3
#lrwx------ 1 root root 64 Jun 28 17​:20 2 -> /dev/tty3
#lr-x------ 1 root root 64 Jun 28 17​:20 3 -> pipe​:[17052173]

#----------------------

# If STDIN is dup'ed before ('' open (FH, '<&=STDIN'); ''),
# then ''close (FH)'' closes FD 0 !
# Else it's - imho - impossible to access FD 0...

Thx,
Daniel Berlin

Perl Info

Flags:
category=core
severity=low

Site configuration information for perl v5.6.1:
Configured by bod at Fri Jan 11 04:14:18 EST 2002.
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=linux, osvers=2.4.13, archname=i386-linux
uname='linux duende 2.4.13 #1 wed oct 31 19:18:07 est 2001 i686 unknown '
config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dp
refix=/usr -Dprivlib=/usr/share/perl/5.6.1 -Darchlib=/usr/lib/perl/5.6.1 -Dv
endorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -D
siteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.1 -Dsitearch=/usr/
local/lib/perl/5.6.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/
man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_c
sh -Uusesfio -Duseshrplib -Dlibperl=libperl.so.5.6.1 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cc', ccflags
='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_
FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.4 (Debian prerelease)', 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=8
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lgdbm -ldb -ldl -lm -lc -lcrypt
perllibs=-ldl -lm -lc -lcrypt
libc=/lib/libc-2.2.4.so, so=so, useshrplib=true, libperl=libperl.so.5.6.1
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:

@INC for perl v5.6.1:
/usr/local/lib/perl/5.6.1
/usr/local/share/perl/5.6.1
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.6.1
/usr/share/perl/5.6.1
/usr/local/lib/site_perl/i386-linux
/usr/local/lib/site_perl
..

Environment for perl v5.6.1:
HOME=/root
LANG=de_DE
LANGUAGE=de_DE
LC_ALL=de_DE
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6
/bin:/scripts:/usr/games
PERL_BADLANG=0
SHELL=/bin/bash




@p5pRT
Copy link
Author

p5pRT commented Dec 31, 2011

From @jkeenan

On Fri Jun 28 01​:38​:02 2002, d@​niel-berlin.de wrote​:

To​: perlbug@​perl.org
Subject​: STDIN inaccessable after undef'ing it
Reply-To​: fw8y079@​public.uni-hamburg.de

This is a bug report for perl from fw8y079@​public.uni-hamburg.de,
generated with the help of perlbug 1.33 running under perl v5.6.1.

-----------------------------------------------------------------
[Please enter your report here]

# This works​:
#
open (FH, '</proc/meminfo') || die; # opens that file

print `ls -l /proc/$$/fd | grep -v total`; # output ok
undef *FH; # close
_and_
undef FH
print `echo;ls -l /proc/$$/fd | grep -v total`; # output ok

#------------------------------

# This makes *STDIN inaccessable without closing it​:
#
undef *STDIN;
print `ls -l /proc/$$/fd | grep -v total`;

# Output #1
#lrwx------ 1 root root 64 Jun 28 17​:20 0 -> /dev/tty3
#lrwx------ 1 root root 64 Jun 28 17​:20 1 -> /dev/tty3
#lrwx------ 1 root root 64 Jun 28 17​:20 2 -> /dev/tty3
#lr-x------ 1 root root 64 Jun 28 17​:20 3 -> pipe​:[17052169]
#lr-x------ 1 root root 64 Jun 28 17​:20 5 -> pipe​:[17052170]

close (STDIN);
print `echo; ls -l /proc/$$/fd | grep -v total`;

# Output #2
#lrwx------ 1 root root 64 Jun 28 17​:20 0 -> /dev/tty3
#lrwx------ 1 root root 64 Jun 28 17​:20 1 -> /dev/tty3
#lrwx------ 1 root root 64 Jun 28 17​:20 2 -> /dev/tty3
#lr-x------ 1 root root 64 Jun 28 17​:20 3 -> pipe​:[17052173]

#----------------------

# If STDIN is dup'ed before ('' open (FH, '<&=STDIN'); ''),
# then ''close (FH)'' closes FD 0 !
# Else it's - imho - impossible to access FD 0...

Thx,
Daniel Berlin

Reviewing this older ticket today, I could not reproduce the original
poster's results for the second part of his example.

I used the following for the second part of the example, and ran it on
perl 5, version 14, subversion 0 (v5.14.0) built for i686-linux​:

#####
$ cat 10006b.pl
#!/usr/local/bin/perl
use strict;
use warnings;

undef *STDIN;
print `ls -l /proc/$$/fd | grep -v total`;

close (STDIN);
print `echo; ls -l /proc/$$/fd | grep -v total`;
#####

Output​:

#####
$ perl 10006b.pl
lrwx------ 1 jimk jimk 64 Dec 31 08​:59 0 -> /dev/pts/0
lrwx------ 1 jimk jimk 64 Dec 31 08​:59 1 -> /dev/pts/0
lrwx------ 1 jimk jimk 64 Dec 31 08​:59 2 -> /dev/pts/0
lr-x------ 1 jimk jimk 64 Dec 31 08​:59 3 -> pipe​:[101535898]
close() on unopened filehandle STDIN at 10006b.pl line 8.

lrwx------ 1 jimk jimk 64 Dec 31 08​:59 0 -> /dev/pts/0
lrwx------ 1 jimk jimk 64 Dec 31 08​:59 1 -> /dev/pts/0
lrwx------ 1 jimk jimk 64 Dec 31 08​:59 2 -> /dev/pts/0
lr-x------ 1 jimk jimk 64 Dec 31 08​:59 3 -> pipe​:[101535912]
#####

However, I don't understand the problem well enough to say whether this
difference supports or refutes the poster's contention. Thoughts?

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Jul 5, 2016

@dcollinsn - Status changed from 'open' to 'abandoned'

@p5pRT p5pRT closed this as completed Jul 5, 2016
@p5pRT
Copy link
Author

p5pRT commented Jul 5, 2016

From @dcollinsn

With no evidence that there is still a problem here, closing the ticket.

@p5pRT
Copy link
Author

p5pRT commented Jul 5, 2016

From [Unknown Contact. See original ticket]

With no evidence that there is still a problem here, closing the ticket.

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