process.getgid()方法是流程模塊的內置應用程序編程接口,用於獲取Node.js流程的數字組標識。
用法:
process.getgid()
參數:此方法不接受任何參數。
返回值:它返回一個對象,該對象指定Node.js進程的數字組標識。
注意:此方法僅適用於POSIX平台。在Windows或Android平台上不可用,因此會導致錯誤,即TypeError,getgid不是函數。
以下示例說明了Node.js中process.getgid()方法的使用:
範例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());輸出:
1000
範例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()); 
}輸出:
The numerical group identity of the Node.js process:1000
注意:上麵的程序將通過使用node filename.js命令。
參考: https://nodejs.org/api/process.html#process_process_getgid
相關用法
注:本文由純淨天空篩選整理自anwesha0107大神的英文原創作品 Node.js | process.getgid() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
