Subject: | leaks fd when loaded |
Date: | Mon, 30 Sep 2013 14:38:57 +0100 |
To: | bug-P [...] rt.cpan.org |
From: | Zefram <zefram [...] fysh.org> |
When P is loaded as a module, the loading process leaves a file descriptor
open for the P::DATA filehandle, which is never closed. I can illustrate
this by examining Linux's /proc/$$/fd directory:
$ perl -Ilib -we 'use P; system("ls -l /proc/$$/fd")'
total 0
lrwx------ 1 zefram zefram 64 Sep 30 14:37 0 -> /dev/pts/5
lrwx------ 1 zefram zefram 64 Sep 30 14:37 1 -> /dev/pts/5
lrwx------ 1 zefram zefram 64 Sep 30 14:37 2 -> /dev/pts/5
lr-x------ 1 zefram zefram 64 Sep 30 14:37 3 -> pipe:[127393829]
lr-x------ 1 zefram zefram 64 Sep 30 14:37 4 -> /home/zefram/usr/perl/perl_install/perl-5.16.3-i64-f52/cpan/build/P-1.0.20-KhxgxS/lib/P.pm
Well-behaved modules avoid leaking such a file descriptor:
$ perl -Ilib -we 'use Data::Dumper; system("ls -l /proc/$$/fd")'
total 0
lrwx------ 1 zefram zefram 64 Sep 30 14:37 0 -> /dev/pts/5
lrwx------ 1 zefram zefram 64 Sep 30 14:37 1 -> /dev/pts/5
lrwx------ 1 zefram zefram 64 Sep 30 14:37 2 -> /dev/pts/5
lr-x------ 1 zefram zefram 64 Sep 30 14:37 3 -> pipe:[127371935]
-zefram