mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
reorg: move JS ops implementations to cli/js/ops/, part 2 (#4283)
Following JS ops were moved to separate files in cli/js/ops directory: - io - process - worker_host - web_worker - plugins - timers - signal - permissions
This commit is contained in:
parent
1b6fc87b71
commit
886f330ec8
20 changed files with 287 additions and 194 deletions
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
|
||||
import { File } from "./files.ts";
|
||||
import { close } from "./ops/resources.ts";
|
||||
import { ReadCloser, WriteCloser } from "./io.ts";
|
||||
import { readAll } from "./buffer.ts";
|
||||
import { assert, unreachable } from "./util.ts";
|
||||
import { build } from "./build.ts";
|
||||
import { kill, runStatus as runStatusOp, run as runOp } from "./ops/process.ts";
|
||||
|
||||
/** How to handle subprocess stdio.
|
||||
*
|
||||
|
@ -31,16 +31,8 @@ export interface RunOptions {
|
|||
stdin?: ProcessStdio | number;
|
||||
}
|
||||
|
||||
interface RunStatusResponse {
|
||||
gotSignal: boolean;
|
||||
exitCode: number;
|
||||
exitSignal: number;
|
||||
}
|
||||
|
||||
async function runStatus(rid: number): Promise<ProcessStatus> {
|
||||
const res = (await sendAsync("op_run_status", {
|
||||
rid
|
||||
})) as RunStatusResponse;
|
||||
const res = await runStatusOp(rid);
|
||||
|
||||
if (res.gotSignal) {
|
||||
const signal = res.exitSignal;
|
||||
|
@ -51,15 +43,6 @@ async function runStatus(rid: number): Promise<ProcessStatus> {
|
|||
}
|
||||
}
|
||||
|
||||
/** Send a signal to process under given PID. Unix only at this moment.
|
||||
* If pid is negative, the signal will be sent to the process group identified
|
||||
* by -pid.
|
||||
* Requires the `--allow-run` flag.
|
||||
*/
|
||||
export function kill(pid: number, signo: number): void {
|
||||
sendSync("op_kill", { pid, signo });
|
||||
}
|
||||
|
||||
export class Process {
|
||||
readonly rid: number;
|
||||
readonly pid: number;
|
||||
|
@ -220,7 +203,7 @@ export function run(opt: RunOptions): Process {
|
|||
stderrRid
|
||||
};
|
||||
|
||||
const res = sendSync("op_run", req) as RunResponse;
|
||||
const res = runOp(req);
|
||||
return new Process(res);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue