Node.js process.getgid() Method
The process.getgid() method is an inbuilt application programming interface of the process module which is used to get the numerical group identity of the Node.js process.
Syntax:
process.getgid()
Parameters: This method does not accept any parameters.
Return Value: It returns an object specifying the numerical group identity of the Node.js process.
Note: This method will only work on POSIX platforms. Not available on windows or android platform so will cause an error i.e. TypeError, getgid is not a function.
Below examples illustrate the use of process.getgid() method in Node.js:
Example 1:
// Node.js program to demonstrate the // process.getgid() method // Include process module const process = require( 'process' ); // Printing the numerical group // identity of the Node.js process console.log(process.getgid()); |
Output:
1000
Example 2:
// Node.js program to demonstrate the // process.getgid() method // Include process module const process = require( 'process' ); // Checking whether this method // exists or not if (process.getgid) { // Printing getgid() value console.log( "The numerical group identity " + "of the Node.js process: " + process.getgid()); } |
Output:
The numerical group identity of the Node.js process: 1000
Note: The above program will compile and run by using the node filename.js
command.
Reference: https://nodejs.org/api/process.html#process_process_getgid
Contact Us