Skip to content

Commit

Permalink
doc: add a example code to API doc property
Browse files Browse the repository at this point in the history
example code added to the process.setgroups() API
doc property in process.md

PR-URL: #35738
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
PoojaDurgad authored and BethGriggs committed Dec 15, 2020
1 parent ec9fae9 commit 4dc5e4a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion doc/api/process.md
Expand Up @@ -2185,7 +2185,18 @@ The `process.setgroups()` method sets the supplementary group IDs for the
Node.js process. This is a privileged operation that requires the Node.js
process to have `root` or the `CAP_SETGID` capability.

The `groups` array can contain numeric group IDs, group names or both.
The `groups` array can contain numeric group IDs, group names, or both.

```js
if (process.getgroups && process.setgroups) {
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).
Expand Down

0 comments on commit 4dc5e4a

Please sign in to comment.