Closed p5pRT closed 20 years ago
This is a bug report for perl from bplatz@acm.org\, generated with the help of perlbug 1.34 running under perl v5.8.0.
-----------------------------------------------------------------
As demonstrated by the example below\, getpwuid seems to leave file descriptors open.
Example:
#!/opt/perl58/bin/perl -w
my @userInfoArray;
open TMP\, "\< /dev/null"; print "before getpwuid fileno(TMP) = "\, fileno(TMP)\, "\n"; close TMP;
@userInfoArray = getpwuid $\<;
open TMP\, "\< /dev/null"; print "after getpwuid fileno(TMP) = "\, fileno(TMP)\, "\n"; close TMP;
open TMP\, "\< /dev/null"; print "after open/close above fileno(TMP) = "\, fileno(TMP)\, "\n"; close TMP;
Output from Perl 5.8.0:
before getpwuid fileno(TMP) = 4 after getpwuid fileno(TMP) = 6 after open/close above fileno(TMP) = 6
@rspier - Status changed from 'new' to 'resolved'
As demonstrated by the example below\, getpwuid seems to leave file descriptors open. osname=solaris\, osvers=2.8\, archname=sun4-solaris
I can't replicate this on Linux.
I suspect this a because of:
Calls to getpwnam() and getpwuid() leave the enumeration position in an indeterminate state.
(from Solaris' man page.)
That implies to me that the handle to the nsswitch provider (generally /etc/passwd) is kept open.
You'll probably see this in the C version too..
#include \<stdio.h> #include \<pwd.h> void main() { FILE *f; struct passwd *p;
f = fopen("/dev/null"\,"r"); printf("fileno is: %d\n"\, fileno(f)); fclose(f);
p = getpwuid(0);
f = fopen("/dev/null"\,"r"); printf("fileno is: %d\n"\, fileno(f)); fclose(f);
f = fopen("/dev/null"\,"r"); printf("fileno is: %d\n"\, fileno(f)); fclose(f); }
And you do...
fileno is: 3 fileno is: 4 fileno is: 4
-R
Migrated from rt.perl.org#30654 (status was 'resolved')
Searchable as RT30654$