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 targos committed Nov 3, 2020
1 parent 86ed87b commit f6aa7c8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,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 f6aa7c8

Please sign in to comment.