diff options
author | Pooja D.P <Pooja.D.P@ibm.com> | 2020-10-21 15:35:27 +0300 |
---|---|---|
committer | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2020-10-25 13:31:08 +0300 |
commit | fc3f41b561b243caca83013e41ff0f4c9eb4fb0a (patch) | |
tree | e6fb5ae49cc3851337b78cf721d817ffade5891b | |
parent | 1f703e120403d41d4f274ad9d30a9512788e5edc (diff) |
doc: add a example code to API doc property
example code added to the process.setgroups() API
doc property in process.md
PR-URL: https://github.com/nodejs/node/pull/35738
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
-rw-r--r-- | doc/api/process.md | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/doc/api/process.md b/doc/api/process.md index fd7e499ee6e..15a3f7bae72 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -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). |