diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> | 2006-09-19 09:08:09 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> | 2006-09-19 09:08:09 +0000 |
commit | 6c70c788d522cfaafd323fc779e078aded2caba1 (patch) | |
tree | fbb53eed1500c8115c998eabb54ce763c5726aa9 /urpm/sys.pm | |
parent | 310bd5c03a5f47b69cf8ad67de8c9e7823063cd4 (diff) | |
download | urpmi-6c70c788d522cfaafd323fc779e078aded2caba1.tar urpmi-6c70c788d522cfaafd323fc779e078aded2caba1.tar.gz urpmi-6c70c788d522cfaafd323fc779e078aded2caba1.tar.bz2 urpmi-6c70c788d522cfaafd323fc779e078aded2caba1.tar.xz urpmi-6c70c788d522cfaafd323fc779e078aded2caba1.zip |
When restarting urpmi, close leaked filehandles. Useful for the upgrade
2006->2007, since the URPM version in 2006 used to leak filehandles.
Diffstat (limited to 'urpm/sys.pm')
-rw-r--r-- | urpm/sys.pm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/urpm/sys.pm b/urpm/sys.pm index dccd05b8..0b191265 100644 --- a/urpm/sys.pm +++ b/urpm/sys.pm @@ -3,6 +3,8 @@ package urpm::sys; # $Id$ use strict; +use warnings; +use POSIX (); (our $VERSION) = q$Revision$ =~ /(\d+)/; @@ -168,6 +170,19 @@ sub mktempdir { return $tmpdir; } +# temporary hack used by urpmi when restarting itself. +sub fix_fd_leak { + opendir my $dirh, "/proc/$$/fd" or return undef; + my @fds = grep { /^(\d+)$/ && $1 > 2 } readdir $dirh; + closedir $dirh; + for (@fds) { + my $link = readlink("/proc/$$/fd/$_"); + $link or next; + next if $link =~ m(^/(usr|dev)/) || $link !~ m(^/); + POSIX::close($_); + } +} + 1; __END__ |