C Notes/ulimit ?

From Federal Burro of Information
Jump to navigationJump to search

#!/usr/bin/perl

use Inline C;
use strict;

my $max = get_max_files();
print $max, "\n";

__END__
__C__
#include <sys/resource.h>

int get_max_files() {

  struct rlimit rl;
  if (getrlimit( RLIMIT_NOFILE, &rl) == 0) {
    return rl.rlim_cur;
  } else {
    return -1;
  }
}