diff options
| author | Ben Noordhuis <info@bnoordhuis.nl> | 2021-11-28 00:45:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-28 00:45:38 +0100 |
| commit | 993a1dd41ae5f96bdb24b09757e24c2ac24126d0 (patch) | |
| tree | 8b6c0d4de8f8101bf8a3c31fe4f163d18c2c298e /runtime/lib.rs | |
| parent | 1d3f734e1815bf1649e0cac445be9eacb4cd296d (diff) | |
feat(runtime): add op_set_exit_code (#12911)
Set the exit code to use if none is provided to Deno.exit(), or when
Deno exits naturally.
Needed for process.exitCode Node compat. Paves the way for #12888.
Diffstat (limited to 'runtime/lib.rs')
| -rw-r--r-- | runtime/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/lib.rs b/runtime/lib.rs index fb6159dd9..ca250ce20 100644 --- a/runtime/lib.rs +++ b/runtime/lib.rs @@ -1,5 +1,7 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +use std::sync::atomic::AtomicI32; + pub use deno_broadcast_channel; pub use deno_console; pub use deno_crypto; @@ -29,3 +31,12 @@ pub mod worker; mod worker_bootstrap; pub use worker_bootstrap::BootstrapOptions; + +// The global may not be very elegant but: +// +// 1. op_exit() calls std::process::exit() so there is not much point storing +// the exit code in runtime state +// +// 2. storing it in runtime state makes retrieving it again in cli/main.rs +// unduly complicated +pub static EXIT_CODE: AtomicI32 = AtomicI32::new(0); |
