Skip to content

Instantly share code, notes, and snippets.

@hartwork
Created January 30, 2015 19:09
Show Gist options
  • Save hartwork/8304364134606af1fca2 to your computer and use it in GitHub Desktop.
Save hartwork/8304364134606af1fca2 to your computer and use it in GitHub Desktop.
Simple tool to dump values of RLIMIT_* resources using getrlimit(2)
/* Simple tool to dump values of RLIMIT_* resources using getrlimit(2)
*
* Copyright (C) Sebastian Pipping <[email protected]>
* Licensed under GPL v2 or later
*
* 2013-11-13
*
* Example output:
* RLIMIT_AS : -1 soft -1 hard
* RLIMIT_CORE : 0 soft -1 hard
* RLIMIT_CPU : -1 soft -1 hard
* RLIMIT_DATA : -1 soft -1 hard
* RLIMIT_FSIZE : -1 soft -1 hard
* RLIMIT_LOCKS : -1 soft -1 hard
* RLIMIT_MEMLOCK : 65536 soft 65536 hard
* RLIMIT_MSGQUEUE : 819200 soft 819200 hard
* RLIMIT_NICE : 0 soft 0 hard
* RLIMIT_NOFILE : 1024 soft 4096 hard
* RLIMIT_NPROC : 63003 soft 63003 hard
* RLIMIT_RSS : -1 soft -1 hard
* RLIMIT_RTPRIO : 0 soft 0 hard
* RLIMIT_RTTIME : -1 soft -1 hard
* RLIMIT_SIGPENDING : 63003 soft 63003 hard
* RLIMIT_STACK : 8388608 soft -1 hard
*/
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
#define SHOW(NAME) \
do { \
struct rlimit limit; \
getrlimit(NAME, &limit); \
printf("%-18s: %10ld soft %10ld hard\n", #NAME, limit.rlim_cur, limit.rlim_max); \
} while(0)
int main() {
SHOW(RLIMIT_AS);
SHOW(RLIMIT_CORE);
SHOW(RLIMIT_CPU);
SHOW(RLIMIT_DATA);
SHOW(RLIMIT_FSIZE);
SHOW(RLIMIT_LOCKS);
SHOW(RLIMIT_MEMLOCK);
SHOW(RLIMIT_MSGQUEUE);
SHOW(RLIMIT_NICE);
SHOW(RLIMIT_NOFILE);
SHOW(RLIMIT_NPROC);
SHOW(RLIMIT_RSS);
SHOW(RLIMIT_RTPRIO);
SHOW(RLIMIT_RTTIME);
SHOW(RLIMIT_SIGPENDING);
SHOW(RLIMIT_STACK);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment