setgid

abstract var setgid: (id: Any) -> Unit?(source)

The process.setgid() method sets the group identity of the process. (See setgid(2).) The id can be passed as either a numeric ID or a group name string. If a group name is specified, this method blocks while resolving the associated numeric ID.

import process from 'node:process';

if (process.getgid && process.setgid) {
console.log(`Current gid: ${process.getgid()}`);
try {
process.setgid(501);
console.log(`New gid: ${process.getgid()}`);
} catch (err) {
console.log(`Failed to set gid: ${err}`);
}
}

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

Since

v0.1.31

Parameters

id

The group name or ID