process.getgroups()


process.getgroups() 方法返回数组,其中包含了补充的组 ID。 如果包含有效的组 ID,则 POSIX 会将其保留为未指定状态,但 Node.js 会确保它始终处于状态。

if (process.getgroups) {
  console.log(process.getgroups()); // [ 16, 21, 297 ]
}

这个函数只在 POSIX 平台有效(在 Windows 或 Android 平台无效)。

The process.getgroups() method returns an array with the supplementary group IDs. POSIX leaves it unspecified if the effective group ID is included but Node.js ensures it always is.

if (process.getgroups) {
  console.log(process.getgroups()); // [ 16, 21, 297 ]
}

This function is only available on POSIX platforms (i.e. not Windows or Android).