From 4dc5e4a35499e3be9a09c235a2b4bbf1547af96c Mon Sep 17 00:00:00 2001 From: "Pooja D.P" Date: Wed, 21 Oct 2020 16:35:27 +0400 Subject: [PATCH] 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 Reviewed-By: Luigi Pinca Reviewed-By: Gireesh Punathil --- doc/api/process.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/api/process.md b/doc/api/process.md index b9d910c371a37a..3f1cd07cda67b0 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -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).