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:
parent
028d8e4d90
commit
57301909cd
6 changed files with 18 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -54,6 +54,8 @@ export default function denoMain() {
|
|||
os.exit(0);
|
||||
}
|
||||
|
||||
os.setPid(startResMsg.pid());
|
||||
|
||||
const cwd = startResMsg.cwd();
|
||||
log("cwd", cwd);
|
||||
|
||||
|
|
8
js/os.ts
8
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;
|
||||
|
|
|
@ -22,3 +22,8 @@ test(async function envFailure() {
|
|||
|
||||
assert(caughtError);
|
||||
});
|
||||
|
||||
test(function osPid() {
|
||||
console.log("pid", deno.pid);
|
||||
assert(deno.pid > 0);
|
||||
});
|
||||
|
|
|
@ -138,6 +138,7 @@ table Start {
|
|||
|
||||
table StartRes {
|
||||
cwd: string;
|
||||
pid: uint32;
|
||||
argv: [string];
|
||||
debug_flag: bool;
|
||||
deps_flag: bool;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue