summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--process.c12
2 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 030bb55372..2dccd00bca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Mar 8 01:43:11 2011 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * process.c (get_sc_ngroups_max): define to wrap sysconf(3).
+ this also supports Windows which doesn't have sysconf(3).
+
+ * process.c (maxgroups): use get_sc_ngroups_max.
+
+ * process.c (proc_setmaxgroups): ditto.
+
Tue Mar 8 01:16:49 2011 NARUSE, Yui <naruse@ruby-lang.org>
* gc.c (rb_objspace): an initializer must be a constant.
diff --git a/process.c b/process.c
index c1832de2a2..a009716208 100644
--- a/process.c
+++ b/process.c
@@ -4542,10 +4542,18 @@ proc_setgid(VALUE obj, VALUE id)
*/
#define RB_MAX_GROUPS (65536)
static int _maxgroups = -1;
+static int get_sc_ngroups_max(void)
+{
+#ifdef _SC_NGROUPS_MAX
+ return (int)sysconf(_SC_NGROUPS_MAX);
+#else
+ return 32;
+#endif
+}
static int maxgroups(void)
{
if (_maxgroups < 0) {
- _maxgroups = (int)sysconf(_SC_NGROUPS_MAX);
+ _maxgroups = get_sc_ngroups_max();
if (_maxgroups < 0)
_maxgroups = RB_MAX_GROUPS;
}
@@ -4729,7 +4737,7 @@ static VALUE
proc_setmaxgroups(VALUE obj, VALUE val)
{
int ngroups = FIX2INT(val);
- int ngroups_max = (int)sysconf(_SC_NGROUPS_MAX);
+ int ngroups_max = get_sc_ngroups_max();
if (ngroups <= 0)
rb_raise(rb_eArgError, "maxgroups %d shold be positive", ngroups);