Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a example code to API doc property in process.md #35738

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,18 @@ process to have `root` or the `CAP_SETGID` capability.

The `groups` array can contain numeric group IDs, group names or both.
PoojaDurgad marked this conversation as resolved.
Show resolved Hide resolved

```js
if (process.getgroups && process.setgroups) {
console.log(process.getgroups()); // current groups
PoojaDurgad marked this conversation as resolved.
Show resolved Hide resolved
try {
process.setgroups([501]);
console.log(process.getgroups()); // new groups
} catch (err) {
console.log(`Failed to set groups: ${err}`);
}
}
```

This function is only available on POSIX platforms (i.e. not Windows or
Android).
This feature is not available in [`Worker`][] threads.
Expand Down