Social Icons

Wednesday, 25 September 2013

getrlimit and setrlimit function

#include <sys/resource.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main (int argc, char *argv[])
{
  struct rlimit limit;
  
  /* Set the file size resource limit. */
  limit.rlim_cur = 65535;
  limit.rlim_max = 65535;
  if (setrlimit(RLIMIT_FSIZE, &limit) != 0) {
    printf("setrlimit() failed with errno=%d\n", errno);
    exit(1);
  }

  /* Get the file size resource limit. */
  if (getrlimit(RLIMIT_FSIZE, &limit) != 0) {
    printf("getrlimit() failed with errno=%d\n", errno);
    exit(1);
  }

  printf("The soft limit is %llu\n", limit.rlim_cur);
  printf("The hard limit is %llu\n", limit.rlim_max);
  exit(0);
}

1 comment:

 

Sample Text

Sample text

 
Just Programming Cse DriveReputation Management