Skip to content

Instantly share code, notes, and snippets.

@cheald
Created November 3, 2014 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheald/f445c84830993fe6ce47 to your computer and use it in GitHub Desktop.
Save cheald/f445c84830993fe6ce47 to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/RubyProcess.java b/core/src/main/java/org/jruby/RubyProcess.java
index 91006dd..e7622db 100644
--- a/core/src/main/java/org/jruby/RubyProcess.java
+++ b/core/src/main/java/org/jruby/RubyProcess.java
@@ -573,7 +573,16 @@ public class RubyProcess {
@JRubyMethod(name = "groups", module = true, visibility = PRIVATE)
public static IRubyObject groups(IRubyObject recv) {
- throw recv.getRuntime().newNotImplementedError("Process#groups not yet implemented");
+ if(Platform.IS_WINDOWS) {
+ throw recv.getRuntime().newNotImplementedError("groups() function is unimplemented on this machine");
+ } else {
+ long[] groups = (new com.sun.security.auth.module.UnixSystem()).getGroups();
+ RubyArray ary = RubyArray.newArray(recv.getRuntime(), groups.length);
+ for(int i = 0; i < groups.length; i++) {
+ ary.push(RubyFixnum.newFixnum(recv.getRuntime(), groups[i]));
+ }
+ return ary;
+ }
}
@JRubyMethod(name = "setrlimit", rest = true, module = true, visibility = PRIVATE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment