process.c:1670
static VALUE
proc_setgroups(VALUE obj, VALUE ary)
{
#ifdef HAVE_SETGROUPS
    size_t ngroups;
    gid_t *groups;
    int i;
    struct group *gr;

    Check_Type(ary, T_ARRAY);

    ngroups = RARRAY(ary)->len;
    if (ngroups > maxgroups)
        rb_raise(rb_eArgError, "too many groups, %d max", maxgroups);

    groups = ALLOCA_N(gid_t, ngroups);

    for (i = 0; i < ngroups; i++) {
        VALUE g = RARRAY(ary)->ptr[i];

	if (FIXNUM_P(g)) {
            groups[i] = FIX2INT(g);
	}
	else {
	    VALUE tmp = rb_check_string_type(g);

	    if (NIL_P(tmp)) {
		groups[i] = NUM2INT(g);
	    }
	    else {
		gr = getgrnam(RSTRING(g)->ptr);
		if (gr == NULL)
		    rb_raise(rb_eArgError, 
			     "can't find group for %s", RSTRING(g)->ptr);
		groups[i] = gr->gr_gid;
	    }
	}
    }

    i = setgroups(ngroups, groups);
    if (i == -1)
        rb_sys_fail(0);

    return proc_getgroups(obj);
#else
    rb_notimplement();
    return Qnil;
#endif
}
