summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-01-06 14:16:42 -0500
committerGitHub <noreply@github.com>2019-01-06 14:16:42 -0500
commit57301909cd9eee6aeaafeda19aab372e034ff7c4 (patch)
tree60e7d9929fe5bd6f46dca5b38b1e70a790170e70 /js
parent028d8e4d90d2224334b44ccb1836dc47d85a9526 (diff)
Add deno.pid (#1464)
Diffstat (limited to 'js')
-rw-r--r--js/deno.ts2
-rw-r--r--js/main.ts2
-rw-r--r--js/os.ts8
-rw-r--r--js/os_test.ts5
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);
diff --git a/js/os.ts b/js/os.ts
index e56aab574..cbcd9c665 100644
--- a/js/os.ts
+++ b/js/os.ts
@@ -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);
+});