My Project  debian-1:4.1.1-p2+ds-4build1
rlimit.c
Go to the documentation of this file.
1 /****************************************
2  * Computer Algebra System SINGULAR *
3  ****************************************/
4 /***************************************************************
5  * File: rlimit.c
6  * Purpose: set resource limits
7  ***************************************************************/
8 
9 #include "rlimit.h"
10 
11 #include <stdint.h>
12 #include <sys/resource.h>
13 
14 /* raise the maximum number of processes (or threads),
15  * return 0 on success,
16  * -1 on error
17  */
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 < 65536)
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 }
raise_rlimit_nproc
int raise_rlimit_nproc()
Definition: rlimit.c:18
res
CanonicalForm res
Definition: facAbsFact.cc:64
rlimit.h