process.title属性是流程模块的内置应用程序编程接口,用于获取和设置流程的标题。
用法:
process.title
返回值:此属性返回一个字符串值,该值指定进程的标题,当前值为“ ps”。
注意:将新值分配给此属性将修改当前值。不同的平台可能会限制进程标题的最大长度。
以下示例说明了Node.js中process.title属性的使用:
范例1:
// Node.js program to demonstrate the
// process.title property
// Include process module
const process = require('process');
// Printing process.title property value
console.log("PID:" + process.pid +
" process title is " + process.title);
输出:
PID:8852 process title is Command Prompt - node title_1
范例2:
// Node.js program to demonstrate the
// process.title property
// Include process module
const process = require('process');
// Printing process.title property value
console.log("Before modification:PID:" + process.pid
+" process title is " + process.title);
// Setting new process title value
process.title = "gekchosCustomProcess";
// Printing process.title value after modification
console.log("After modification:PID:" + process.pid
+ " process title is " + process.title);
输出:
Before modification:PID:14012 process title is Command Prompt - node title_2 After modification:PID:14012 process title is gekchosCustomProcess
注意:上面的程序将通过使用node filename.js
命令。
参考: https://nodejs.org/api/process.html#process_process_title
相关用法
注:本文由纯净天空筛选整理自anwesha0107大神的英文原创作品 Node.js | process.title Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。