-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path003.c
More file actions
34 lines (28 loc) · 1 KB
/
003.c
File metadata and controls
34 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
..........................................................................................................................................
Name : 003.c
Author : SHRUTI VERMA
Description : Write a program to set (any one) system resource limit. Use setrlimit system call.
Date : 29 Sep 2025
..........................................................................................................................................
*/
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<sys/resource.h>
int main() {
struct rlimit rl;
getrlimit(RLIMIT_LOCKS, &rl);
int l = rl.rlim_max;
printf("Hard Limit on locks before : ");
if(l == RLIM_INFINITY)
printf("UNLIMITED\n");
else printf("%ld", (long)rl.rlim_max);
rl.rlim_max = 10;
setrlimit(RLIMIT_LOCKS, &rl);
printf("Hard Limit on locks now : %ld\n", (long)rl.rlim_max);
}
/* ------------------------------OUTPUT----------------------------
Hard Limit on locks before : UNLIMITED
Hard Limit on locks now : 10
*/