0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

Add deno.pid (#1464)

This commit is contained in:
Ryan Dahl 2019-01-06 14:16:42 -05:00 committed by GitHub
parent 028d8e4d90
commit 57301909cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 1 deletions

View file

@ -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,

View file

@ -54,6 +54,8 @@ export default function denoMain() {
os.exit(0);
}
os.setPid(startResMsg.pid());
const cwd = startResMsg.cwd();
log("cwd", cwd);

View file

@ -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;

View file

@ -22,3 +22,8 @@ test(async function envFailure() {
assert(caughtError);
});
test(function osPid() {
console.log("pid", deno.pid);
assert(deno.pid > 0);
});

View file

@ -138,6 +138,7 @@ table Start {
table StartRes {
cwd: string;
pid: uint32;
argv: [string];
debug_flag: bool;
deps_flag: bool;

View file

@ -201,6 +201,7 @@ fn op_start(
&mut builder,
&msg::StartResArgs {
cwd: Some(cwd_off),
pid: std::process::id(),
argv: Some(argv_off),
debug_flag: state.flags.log_debug,
recompile_flag: state.flags.recompile,