jengelh-datetimespielwiese
Last change
on this file since 1f400b was
1f400b,
checked in by Hans Schoenemann <hannes@…>, 9 years ago
|
port: freebsd needs uint64_t in rlimit.c
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /*************************************************************** |
---|
5 | * File: rlimit.c |
---|
6 | * Purpose: set resource limits |
---|
7 | ***************************************************************/ |
---|
8 | |
---|
9 | #include <stdint.h> |
---|
10 | #include <sys/resource.h> |
---|
11 | |
---|
12 | #include "rlimit.h" |
---|
13 | |
---|
14 | /* raise the maximum number of processes (or threads), |
---|
15 | * return 0 on success, |
---|
16 | * -1 on error |
---|
17 | */ |
---|
18 | int raise_rlimit_nproc() |
---|
19 | { |
---|
20 | #ifdef RLIMIT_NPROC |
---|
21 | struct rlimit nproc; |
---|
22 | getrlimit(RLIMIT_NPROC, &nproc); |
---|
23 | if (nproc.rlim_cur == RLIM_INFINITY |
---|
24 | || (nproc.rlim_max != RLIM_INFINITY && nproc.rlim_cur >= nproc.rlim_max)) |
---|
25 | { |
---|
26 | return(-1); |
---|
27 | } |
---|
28 | if (nproc.rlim_cur < 512) |
---|
29 | { |
---|
30 | nproc.rlim_cur = 512; |
---|
31 | } |
---|
32 | if ((nproc.rlim_max == RLIM_INFINITY || 2*nproc.rlim_cur <= nproc.rlim_max) |
---|
33 | && nproc.rlim_cur < 2*nproc.rlim_cur) |
---|
34 | { |
---|
35 | nproc.rlim_cur = 2*nproc.rlim_cur; |
---|
36 | } |
---|
37 | else |
---|
38 | { |
---|
39 | nproc.rlim_cur = nproc.rlim_max; |
---|
40 | } |
---|
41 | int res = setrlimit(RLIMIT_NPROC, &nproc); |
---|
42 | return(res); |
---|
43 | #else |
---|
44 | return(-1); |
---|
45 | #endif |
---|
46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.