Node.js process.stderr.fd 属性
process.stderr.fd是process 模块内Process 类的内置应用程序编程接口,用于返回process.stderr 的底层文件描述符的值。
句法:
const process.stderr.fd
参数:此 api 不接受任何参数作为参数。
返回值:该api返回process.stderr的底层文件描述符的值。
示例 1:
index.js
// Node.js program to demonstrate the
// process.stderr.fd
// Importing process module
const process = require('process');
// Getting the value of file descriptor
// by using process.stderr.fd
const value = process.stderr.fd
// Display the result
console.log(value)
index.js
// Node.js program to demonstrate the
// process.stderr.fd
// Importing process module
const process = require('process');
// Updating file descriptor value
process.stderr.fd = 10
// Getting the value of file descriptor
// by using process.stderr.fd
const value = process.stderr.fd
// Display the result
console.log(value)
使用以下命令运行index.js文件:
node index.js
输出:
2
示例 2:
index.js
// Node.js program to demonstrate the
// process.stderr.fd
// Importing process module
const process = require('process');
// Updating file descriptor value
process.stderr.fd = 10
// Getting the value of file descriptor
// by using process.stderr.fd
const value = process.stderr.fd
// Display the result
console.log(value)
使用以下命令运行index.js文件:
node index.js
输出:
10
参考: https://nodejs.org/dist/latest-v16.x/docs/api/process.html#process_process_stderr_fd