Project

General

Profile

Bug #3813 » rlimit-constants-2.patch

runpaint (Run Paint Run Run), 09/12/2010 06:22 AM

View differences:

process.c
#ifdef RLIMIT_MEMLOCK
RESCHECK(MEMLOCK);
#endif
#ifdef RLIMIT_MSGQUEUE
RESCHECK(MSGQUEUE);
#endif
break;
case 'N':
......
#ifdef RLIMIT_NPROC
RESCHECK(NPROC);
#endif
#ifdef RLIMIT_NICE
RESCHECK(NICE);
#endif
break;
case 'R':
#ifdef RLIMIT_RSS
RESCHECK(RSS);
#endif
#ifdef RLIMIT_RTPRIO
RESCHECK(RTPRIO);
#endif
#ifdef RLIMIT_RTTIME
RESCHECK(RTTIME);
#endif
break;
case 'S':
......
#ifdef RLIMIT_SBSIZE
RESCHECK(SBSIZE);
#endif
#ifdef RLIMIT_SIGPENDING
RESCHECK(SIGPENDING);
#endif
break;
}
return -1;
......
* The available resources are OS dependent.
* Ruby may support following resources.
*
* [AS] total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite)
* [CORE] core size (bytes) (SUSv3)
* [CPU] CPU time (seconds) (SUSv3)
* [DATA] data segment (bytes) (SUSv3)
* [FSIZE] file size (bytes) (SUSv3)
* [NOFILE] file descriptors (number) (SUSv3)
* [STACK] stack size (bytes) (SUSv3)
* [AS] total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite)
* [MEMLOCK] total size for mlock(2) (bytes) (4.4BSD, GNU/Linux)
* [MSGQUEUE] allocation for POSIX message queues (bytes) (GNU/Linux)
* [NICE] ceiling on process's nice(2) value (number) (GNU/Linux)
* [NOFILE] file descriptors (number) (SUSv3)
* [NPROC] number of processes for the user (number) (4.4BSD, GNU/Linux)
* [RSS] resident memory size (bytes) (4.2BSD, GNU/Linux)
* [RTPRIO] ceiling on the process's real-time priority (number) (GNU/Linux)
* [RTTIME] CPU time for real-time process (us) (GNU/Linux)
* [SBSIZE] all socket buffers (bytes) (NetBSD, FreeBSD)
* [SIGPENDING] number of queued signals allowed (signals) (GNU/Linux)
* [STACK] stack size (bytes) (SUSv3)
*
* _cur_limit_ and _max_limit_ may be
* <code>:INFINITY</code>, <code>"INFINITY"</code> or
......
* corresponding symbols and strings too.
* See system setrlimit(2) manual for details.
*
* The following example raise the soft limit of core size to
* The following example raises the soft limit of core size to
* the hard limit to try to make core dump possible.
*
* Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1])
......
}
#endif
}
#ifdef RLIMIT_AS
rb_define_const(rb_mProcess, "RLIMIT_AS", INT2FIX(RLIMIT_AS));
#endif
#ifdef RLIMIT_CORE
rb_define_const(rb_mProcess, "RLIMIT_CORE", INT2FIX(RLIMIT_CORE));
#endif
......
#ifdef RLIMIT_FSIZE
rb_define_const(rb_mProcess, "RLIMIT_FSIZE", INT2FIX(RLIMIT_FSIZE));
#endif
#ifdef RLIMIT_NOFILE
rb_define_const(rb_mProcess, "RLIMIT_NOFILE", INT2FIX(RLIMIT_NOFILE));
#ifdef RLIMIT_MEMLOCK
rb_define_const(rb_mProcess, "RLIMIT_MEMLOCK", INT2FIX(RLIMIT_MEMLOCK));
#endif
#ifdef RLIMIT_STACK
rb_define_const(rb_mProcess, "RLIMIT_STACK", INT2FIX(RLIMIT_STACK));
#ifdef RLIMIT_MSGQUEUE
rb_define_const(rb_mProcess, "RLIMIT_MSGQUEUE", INT2FIX(RLIMIT_MSGQUEUE));
#endif
#ifdef RLIMIT_AS
rb_define_const(rb_mProcess, "RLIMIT_AS", INT2FIX(RLIMIT_AS));
#ifdef RLIMIT_NICE
rb_define_const(rb_mProcess, "RLIMIT_NICE", INT2FIX(RLIMIT_NICE));
#endif
#ifdef RLIMIT_MEMLOCK
rb_define_const(rb_mProcess, "RLIMIT_MEMLOCK", INT2FIX(RLIMIT_MEMLOCK));
#ifdef RLIMIT_NOFILE
rb_define_const(rb_mProcess, "RLIMIT_NOFILE", INT2FIX(RLIMIT_NOFILE));
#endif
#ifdef RLIMIT_NPROC
rb_define_const(rb_mProcess, "RLIMIT_NPROC", INT2FIX(RLIMIT_NPROC));
......
#ifdef RLIMIT_RSS
rb_define_const(rb_mProcess, "RLIMIT_RSS", INT2FIX(RLIMIT_RSS));
#endif
#ifdef RLIMIT_RTPRIO
rb_define_const(rb_mProcess, "RLIMIT_RTPRIO", INT2FIX(RLIMIT_RTPRIO));
#endif
#ifdef RLIMIT_RTTIME
rb_define_const(rb_mProcess, "RLIMIT_RTTIME", INT2FIX(RLIMIT_RTTIME));
#endif
#ifdef RLIMIT_SBSIZE
rb_define_const(rb_mProcess, "RLIMIT_SBSIZE", INT2FIX(RLIMIT_SBSIZE));
#endif
#ifdef RLIMIT_SIGPENDING
rb_define_const(rb_mProcess, "RLIMIT_SIGPENDING", INT2FIX(RLIMIT_SIGPENDING));
#endif
#ifdef RLIMIT_STACK
rb_define_const(rb_mProcess, "RLIMIT_STACK", INT2FIX(RLIMIT_STACK));
#endif
#endif
rb_define_module_function(rb_mProcess, "uid", proc_getuid, 0);
test/ruby/test_process.rb
:DATA, "DATA",
:FSIZE, "FSIZE",
:MEMLOCK, "MEMLOCK",
:MSGQUEUE, "MSGQUEUE",
:NICE, "NICE",
:NOFILE, "NOFILE",
:NPROC, "NPROC",
:RSS, "RSS",
:STACK, "STACK",
:RTPRIO, "RTPRIO",
:RTTIME, "RTTIME",
:SBSIZE, "SBSIZE",
:SIGPENDING, "SIGPENDING",
:STACK, "STACK",
].each {|name|
if Process.const_defined? "RLIMIT_#{name}"
assert_nothing_raised { Process.getrlimit(name) }
(3-3/3)