温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/child_process/ChildProcess/stdio
点击访问原文链接

ChildProcess.stdio property | Node.js child_process module | Bun

ChildProcess.stdio property | Node.js child_process module | BunBuildDocsReferenceGuidesBlogDiscord/node:child_process/ChildProcess/stdioPstdio

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:child_process/ChildProcess/stdioPstdio

property

child_process.ChildProcess.stdioreadonly stdio: [null | Writable, null | Readable, null | Readable, undefined | null | Writable | Readable, undefined | null | Writable | Readable]A sparse array of pipes to the child process, corresponding with positions in the stdio option passed to spawn that have been set to the value 'pipe'. subprocess.stdio[0], subprocess.stdio[1], and subprocess.stdio[2] are also available as subprocess.stdin, subprocess.stdout, and subprocess.stderr, respectively.

In the following example, only the child's fd 1 (stdout) is configured as a pipe, so only the parent's subprocess.stdio[1] is a stream, all other values in the array are null.

import assert from 'node:assert'; import fs from 'node:fs'; import child_process from 'node:child_process'; const subprocess = child_process.spawn('ls', { stdio: [ 0, // Use parent's stdin for child. 'pipe', // Pipe child's stdout to parent. fs.openSync('err.out', 'w'), // Direct child's stderr to a file. ], }); assert.strictEqual(subprocess.stdio[0], null); assert.strictEqual(subprocess.stdio[0], subprocess.stdin); assert(subprocess.stdout); assert.strictEqual(subprocess.stdio[1], subprocess.stdout); assert.strictEqual(subprocess.stdio[2], null); assert.strictEqual(subprocess.stdio[2], subprocess.stderr); The subprocess.stdio property can be undefined if the child process could not be successfully spawned.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录