diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-01 14:15:30 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-01 14:15:30 +0000 |
commit | 1425eea04dd872dc6313f5315f317b2de288037c (patch) | |
tree | f81c74f75429e829714029850f89ee4c7f13aa39 /lib/IO/Async/OS/linux.pm | |
download | IO-Async-tarball-master.tar.gz |
IO-Async-0.67HEADIO-Async-0.67master
Diffstat (limited to 'lib/IO/Async/OS/linux.pm')
-rw-r--r-- | lib/IO/Async/OS/linux.pm | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/IO/Async/OS/linux.pm b/lib/IO/Async/OS/linux.pm new file mode 100644 index 0000000..c12949b --- /dev/null +++ b/lib/IO/Async/OS/linux.pm @@ -0,0 +1,59 @@ +# You may distribute under the terms of either the GNU General Public License +# or the Artistic License (the same terms as Perl itself) +# +# (C) Paul Evans, 2014-2015 -- leonerd@leonerd.org.uk + +package IO::Async::OS::linux; + +use strict; +use warnings; + +our $VERSION = '0.67'; + +our @ISA = qw( IO::Async::OS::_Base ); + +=head1 NAME + +C<IO::Async::OS::linux> - operating system abstractions on C<Linux> for C<IO::Async> + +=head1 DESCRIPTION + +This module contains OS support code for C<Linux>. + +See instead L<IO::Async::OS>. + +=cut + +# Suggest either Epoll or Ppoll loops first if they are installed +use constant LOOP_PREFER_CLASSES => qw( Epoll Ppoll ); + +# Try to use /proc/pid/fd to get the list of actually-open file descriptors +# for our process. Saves a bit of time when running with high ulimit -n / +# fileno counts. +sub potentially_open_fds +{ + my $class = shift; + + opendir my $fd_path, "/proc/$$/fd" or do { + warn "Cannot open /proc/$$/fd, falling back to generic method - $!"; + return $class->SUPER::potentially_open_fds + }; + + # Skip ., .., our directory handle itself and any other cruft + # except fileno() isn't available for the handle so we'll + # end up with that in the output anyway. As long as we're + # called just before the relevant close() loop, this + # should be harmless enough. + my @fd = map { m/^([0-9]+)$/ ? $1 : () } readdir $fd_path; + closedir $fd_path; + + return @fd; +} + +=head1 AUTHOR + +Paul Evans <leonerd@leonerd.org.uk> + +=cut + +0x55AA; |