root/orte/test/system/get_limits.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 #include <stdio.h>
   2 #include <stdlib.h>
   3 #include <sys/types.h>
   4 #include <unistd.h>
   5 #include <errno.h>
   6 #include <sys/resource.h>
   7 #include <string.h>
   8 
   9 int main(int argc, char* argv[])
  10 {
  11     struct rlimit rlim;
  12 
  13     if (getrlimit (RLIMIT_NOFILE, &rlim) < 0)
  14         fprintf (stderr, "getrlimit (RLIMIT_NOFILE): %s\n", strerror (errno));
  15     else {
  16         printf("softlimit on num_files: %d\thardlimit on num_files: %d\n", (int)rlim.rlim_cur, (int)rlim.rlim_max);
  17     }
  18     if (getrlimit (RLIMIT_NPROC, &rlim) < 0)
  19         fprintf (stderr, "getrlimit (RLIMIT_NPROC): %s\n", strerror (errno));
  20     else {
  21         printf("softlimit on num_child: %d\thardlimit on num_child: %d\n", (int)rlim.rlim_cur, (int)rlim.rlim_max);
  22     }
  23 
  24     printf("RLIM_INFINITY: %d\n", (int)RLIM_INFINITY);
  25 
  26     return 0;
  27 }
  28 
  29 #if 0
  30 int nfds_needed = calculate_nfds_needed (nprocs);
  31 if (nfds_needed > rlim->rlim_cur) {
  32     if (nfds_needed <= rlim->rlim_max)
  33         rlim->rlim_cur = rlim->rlim_max;
  34     if (setrlimit (RLIMIT_NOFILE, rlim) < 0)
  35         fprintf (stderr, "setrlimit (RLIMIT_NOFILE, cur = %d): %m\n";
  36                  else
  37                  fprintf (stderr, "Hard limit for number of open files is too low\n");
  38     }
  39 #endif

/* [<][>][^][v][top][bottom][index][help] */