mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
chore(runtime): internalize pipe fd for ext/node (#21570)
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
This commit is contained in:
parent
4de9ddcf21
commit
a7b21760fc
2 changed files with 12 additions and 9 deletions
|
@ -6,6 +6,7 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
|
import { core, internals } from "ext:core/mod.js";
|
||||||
import { assert } from "ext:deno_node/_util/asserts.ts";
|
import { assert } from "ext:deno_node/_util/asserts.ts";
|
||||||
import { EventEmitter } from "node:events";
|
import { EventEmitter } from "node:events";
|
||||||
import { os } from "ext:deno_node/internal_binding/constants.ts";
|
import { os } from "ext:deno_node/internal_binding/constants.ts";
|
||||||
|
@ -43,6 +44,7 @@ import {
|
||||||
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
|
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
|
||||||
import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs";
|
import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs";
|
||||||
import process from "node:process";
|
import process from "node:process";
|
||||||
|
|
||||||
const core = globalThis.__bootstrap.core;
|
const core = globalThis.__bootstrap.core;
|
||||||
const {
|
const {
|
||||||
op_node_ipc_read,
|
op_node_ipc_read,
|
||||||
|
@ -258,8 +260,9 @@ export class ChildProcess extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof this.#process._pipeFd == "number") {
|
const pipeFd = internals.getPipeFd(this.#process);
|
||||||
setupChannel(this, this.#process._pipeFd);
|
if (typeof pipeFd == "number") {
|
||||||
|
setupChannel(this, pipeFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const ops = core.ops;
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
|
@ -204,16 +204,16 @@ function collectOutput(readableStream) {
|
||||||
return readableStreamCollectIntoUint8Array(readableStream);
|
return readableStreamCollectIntoUint8Array(readableStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const _pipeFd = Symbol("[[pipeFd]]");
|
||||||
|
|
||||||
|
internals.getPipeFd = (process) => process[_pipeFd];
|
||||||
|
|
||||||
class ChildProcess {
|
class ChildProcess {
|
||||||
#rid;
|
#rid;
|
||||||
#waitPromise;
|
#waitPromise;
|
||||||
#waitComplete = false;
|
#waitComplete = false;
|
||||||
|
|
||||||
#pipeFd;
|
[_pipeFd];
|
||||||
// internal, used by ext/node
|
|
||||||
get _pipeFd() {
|
|
||||||
return this.#pipeFd;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pid;
|
#pid;
|
||||||
get pid() {
|
get pid() {
|
||||||
|
@ -259,7 +259,7 @@ class ChildProcess {
|
||||||
|
|
||||||
this.#rid = rid;
|
this.#rid = rid;
|
||||||
this.#pid = pid;
|
this.#pid = pid;
|
||||||
this.#pipeFd = pipeFd;
|
this[_pipeFd] = pipeFd;
|
||||||
|
|
||||||
if (stdinRid !== null) {
|
if (stdinRid !== null) {
|
||||||
this.#stdin = writableStreamForRid(stdinRid);
|
this.#stdin = writableStreamForRid(stdinRid);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue