diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/deno.ts | 2 | ||||
-rw-r--r-- | js/main.ts | 2 | ||||
-rw-r--r-- | js/os.ts | 8 | ||||
-rw-r--r-- | js/os_test.ts | 5 |
4 files changed, 16 insertions, 1 deletions
diff --git a/js/deno.ts b/js/deno.ts index 2e82613e8..07068ca31 100644 --- a/js/deno.ts +++ b/js/deno.ts @@ -2,7 +2,7 @@ // Public deno module. /// <amd-module name="deno"/> -export { env, exit } from "./os"; +export { pid, env, exit } from "./os"; export { chdir, cwd } from "./dir"; export { File, diff --git a/js/main.ts b/js/main.ts index 818713593..9ecdefc93 100644 --- a/js/main.ts +++ b/js/main.ts @@ -54,6 +54,8 @@ export default function denoMain() { os.exit(0); } + os.setPid(startResMsg.pid()); + const cwd = startResMsg.cwd(); log("cwd", cwd); @@ -5,6 +5,14 @@ import * as util from "./util"; import * as flatbuffers from "./flatbuffers"; import { sendSync } from "./dispatch"; +/** process id */ +export let pid: number; + +export function setPid(pid_: number): void { + assert(!pid); + pid = pid_; +} + interface CodeInfo { moduleName: string | undefined; filename: string | undefined; diff --git a/js/os_test.ts b/js/os_test.ts index 922d86850..4b7ec4543 100644 --- a/js/os_test.ts +++ b/js/os_test.ts @@ -22,3 +22,8 @@ test(async function envFailure() { assert(caughtError); }); + +test(function osPid() { + console.log("pid", deno.pid); + assert(deno.pid > 0); +}); |