Created
July 14, 2010 09:24
-
-
Save maoe/475235 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/time.h> | |
#include <sys/resource.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct rlimit rlimit_t; | |
int main(void) | |
{ | |
rlimit_t *r = (rlimit_t *) malloc(sizeof(struct rlimit)); | |
getrlimit(RLIMIT_NOFILE, r); | |
printf("FILE: cur %d, max %d\n", (int) r->rlim_cur, (int) r->rlim_max); | |
rlimit_t *new_r = (rlimit_t *) malloc(sizeof(struct rlimit)); | |
new_r->rlim_cur = (rlim_t) 2048; | |
new_r->rlim_max = (rlim_t) 2048; | |
if (setrlimit(RLIMIT_NOFILE, new_r)) { | |
perror("setrlimit failed"); | |
} | |
getrlimit(RLIMIT_NOFILE, r); | |
printf("FILE: cur %d, max %d\n", (int) r->rlim_cur, (int) r->rlim_max); | |
free(new_r); | |
free(r); | |
return 0; | |
} |
Author
maoe
commented
Jul 14, 2010
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment