summaryrefslogtreecommitdiff
path: root/cli/js/process.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-09 15:18:02 +0100
committerGitHub <noreply@github.com>2020-03-09 15:18:02 +0100
commit886f330ec8110a3eb72feb14353f353962179d2e (patch)
treef6b458afac30a18d5120396bed9b1e63ae6d8529 /cli/js/process.ts
parent1b6fc87b7188118896f797e5f0dab309775def71 (diff)
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
Diffstat (limited to 'cli/js/process.ts')
-rw-r--r--cli/js/process.ts23
1 files changed, 3 insertions, 20 deletions
diff --git a/cli/js/process.ts b/cli/js/process.ts
index dc1af51ce..3e5cc8ea0 100644
--- a/cli/js/process.ts
+++ b/cli/js/process.ts
@@ -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);
}