Module: OsCtld::PrLimits
- Defined in:
- ext/osctld/native.c,
 lib/osctld.rb,
 lib/osctld/prlimits.rb
Defined Under Namespace
Constant Summary collapse
- AS =
- INT2NUM(RLIMIT_AS) 
- CORE =
- INT2NUM(RLIMIT_CORE) 
- CPU =
- INT2NUM(RLIMIT_CPU) 
- DATA =
- INT2NUM(RLIMIT_DATA) 
- FSIZE =
- INT2NUM(RLIMIT_FSIZE) 
- LOCKS =
- INT2NUM(RLIMIT_LOCKS) 
- MEMLOCK =
- INT2NUM(RLIMIT_MEMLOCK) 
- MSGQUEUE =
- INT2NUM(RLIMIT_MSGQUEUE) 
- NICE =
- INT2NUM(RLIMIT_NICE) 
- NOFILE =
- INT2NUM(RLIMIT_NOFILE) 
- NPROC =
- INT2NUM(RLIMIT_NPROC) 
- RSS =
- INT2NUM(RLIMIT_RSS) 
- RTPRIO =
- INT2NUM(RLIMIT_RTPRIO) 
- RTTIME =
- INT2NUM(RLIMIT_RTTIME) 
- SIGPENDING =
- INT2NUM(RLIMIT_SIGPENDING) 
- STACK =
- INT2NUM(RLIMIT_STACK) 
- INFINITY =
- ULONG2NUM(RLIM_INFINITY) 
Class Method Summary collapse
- .resource_to_const(resource) ⇒ Integer
- 
  
    
      .set(pid, resource, soft, hard)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Set process resource limit. 
Class Method Details
.resource_to_const(resource) ⇒ Integer
| 5 6 7 | # File 'lib/osctld/prlimits.rb', line 5 def self.resource_to_const(resource) PrLimits.const_get(resource.upcase) end | 
.set(pid, resource, soft, hard) ⇒ Boolean
| 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # File 'ext/osctld/native.c', line 21
VALUE osctld_prlimits_set(VALUE self, VALUE vPid, VALUE vResource, VALUE vSoft, VALUE vHard)
{
	pid_t pid = (pid_t) NUM2LONG(vPid);
	int resource = NUM2INT(vResource);
	struct rlimit limit = {
		.rlim_cur = (rlim_t) NUM2ULONG(vSoft),
		.rlim_max = (rlim_t) NUM2ULONG(vHard)
	};
	int ret;
	char error[255];
	if ((ret = prlimit(pid, resource, &limit, NULL)) == 0)
		return Qtrue;
	rb_raise(
		rb_eSystemCallError,
		"prlimit() failed: %d - %s",
		ret, strerror_r(errno, error, sizeof(error))
	);
} |