aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--process.c13
-rw-r--r--spec/ruby/core/process/groups_spec.rb4
2 files changed, 15 insertions, 2 deletions
diff --git a/process.c b/process.c
index be583be6e3..ba800b9058 100644
--- a/process.c
+++ b/process.c
@@ -6136,6 +6136,19 @@ maxgroups(void)
*
* Process.groups #=> [27, 6, 10, 11]
*
+ * Note that this method is just a wrapper of getgroups(2).
+ * This means that the following characteristics of
+ * the results are completely depends on your system:
+ *
+ * - the result is sorted
+ * - the result includes effective GIDs
+ * - the result does not include duplicated GIDs
+ *
+ * You can certainly get a sorted unique GID list of
+ * the current process by this expression:
+ *
+ * Process.groups.unique.sort
+ *
*/
static VALUE
diff --git a/spec/ruby/core/process/groups_spec.rb b/spec/ruby/core/process/groups_spec.rb
index 331c53939a..325deb5977 100644
--- a/spec/ruby/core/process/groups_spec.rb
+++ b/spec/ruby/core/process/groups_spec.rb
@@ -6,8 +6,8 @@ describe "Process.groups" do
groups = `id -G`.scan(/\d+/).map { |i| i.to_i }
gid = Process.gid
- expected = (groups.sort - [gid]).sort
- actual = (Process.groups - [gid]).sort
+ expected = (groups.sort - [gid]).uniq.sort
+ actual = (Process.groups - [gid]).uniq.sort
actual.should == expected
end
end