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

local *DIRHANDLE doesn't close when out of scope #2025

Closed
p5pRT opened this issue May 30, 2000 · 3 comments
Closed

local *DIRHANDLE doesn't close when out of scope #2025

p5pRT opened this issue May 30, 2000 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented May 30, 2000

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

Searchable as RT3303$

@p5pRT
Copy link
Author

p5pRT commented May 30, 2000

From joepepin@att.com

Created by jpepin@marvin.isc.att.com

local (*DH);
opendir(DH, '.');

The dirhandle doesn't seem to close when DH goes out of scope and chews up
a file descriptor. Eventually, I run out of file descriptors.

Also, fileno DH doesn't work.

Perl Info


Site configuration information for perl 5.00503:

Configured by jpepin at Tue Mar 14 09:15:18 EST 2000.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos marvin 5.6 generic_105181-05 sun4u sparc sunw,ultra-60 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.8.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/local/lib/perl5/5.00503/sun4-solaris
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/export/home/jpepin
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
 
PATH=/usr/bin:/usr/ucb:/etc:.:/opt/NSCPcom:/usr/dt/bin:/usr/openwin/bin:/exp
ort/home/jpepin/bin:/usr/local/bin:/usr/ccs/bin:/usr/sbin:/usr/local/samba/b
in
    PERL_BADLANG (unset)
    SHELL=/bin/ksh



@p5pRT
Copy link
Author

p5pRT commented Oct 24, 2004

From @smpeters

[joepepin@​att.com - Tue May 30 02​:05​:20 2000]​:

This is a bug report for perl from jpepin@​marvin.isc.att.com,
generated with the help of perlbug 1.26 running under perl 5.00503.

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

local (*DH);
opendir(DH, '.');

The dirhandle doesn't seem to close when DH goes out of scope and chews up
a file descriptor. Eventually, I run out of file descriptors.

Also, fileno DH doesn't work.

Looking at the following strace, I just do not see that the close is not
occuring.

#!/usr/bin/perl -w
use strict;
print "pid​: $$\n";
{
  local (*DH);
  opendir(DH, '.');
}
print "Out of scope\n";

Below is the end (and important part) of the strace output.
write(1, "pid​: 29825\n", 12pid​: 29825
) = 12
open("/dev/null", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = -1 ENOTDIR (Not a
directory)
open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3
fstat64(3, {st_mode=S_IFDIR|0777, st_size=3824, ...}) = 0
fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
close(3) = 0
write(1, "Out of scope\n", 13Out of scope
) = 13
exit_group(0) = ?

The open on the directory returns an fd of 3. Before "Out of scope" is
printed, a close(3) is performed. I don't know if this was fixed with
the PerlIO changes, but it doesn't appear to be a problem now.

@p5pRT
Copy link
Author

p5pRT commented Oct 24, 2004

@smpeters - Status changed from 'open' 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