| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2664536 commit 75c1d1b
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -121,6 +121,9 @@ changes: | |||
| 121 | 121 | - version: v20.0.0 | |
| 122 | 122 | pr-url: https://github.com/nodejs/node/pull/47391 | |
| 123 | 123 | description: The version option is now required and has no default value. | |
| 124 | + - version: REPLACEME | ||
| 125 | + pr-url: https://github.com/nodejs/node/pull/47390 | ||
| 126 | + description: default value of returnOnExit changed to true. | ||
| 124 | 127 | - version: v19.8.0 | |
| 125 | 128 | pr-url: https://github.com/nodejs/node/pull/46469 | |
| 126 | 129 | description: version field added to options. | |
@@ -136,10 +139,11 @@ changes: | |||
| 136 | 139 | sandbox directory structure. The string keys of `preopens` are treated as | |
| 137 | 140 | directories within the sandbox. The corresponding values in `preopens` are | |
| 138 | 141 | the real paths to those directories on the host machine. | |
| 139 | - * `returnOnExit` {boolean} By default, WASI applications terminate the Node.js | ||
| 140 | - process via the `__wasi_proc_exit()` function. Setting this option to `true` | ||
| 141 | - causes `wasi.start()` to return the exit code rather than terminate the | ||
| 142 | - process. **Default:** `false`. | ||
| 142 | + * `returnOnExit` {boolean} By default, when WASI applications call | ||
| 143 | + `__wasi_proc_exit()` `wasi.start()` will return with the exit code | ||
| 144 | + specified rather than terminatng the process. Setting this option to | ||
| 145 | + `false` will cause the Node.js process to exit with the specified | ||
| 146 | + exit code instead. **Default:** `true`. | ||
| 143 | 147 | * `stdin` {integer} The file descriptor used as standard input in the | |
| 144 | 148 | WebAssembly application. **Default:** `0`. | |
| 145 | 149 | * `stdout` {integer} The file descriptor used as standard output in the | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -102,11 +102,13 @@ class WASI { | |||
| 102 | 102 | wrap[prop] = FunctionPrototypeBind(wrap[prop], wrap); | |
| 103 | 103 | } | |
| 104 | 104 | ||
| 105 | + let returnOnExit = true; | ||
| 105 | 106 | if (options.returnOnExit !== undefined) { | |
| 106 | 107 | validateBoolean(options.returnOnExit, 'options.returnOnExit'); | |
| 107 | - if (options.returnOnExit) | ||
| 108 | - wrap.proc_exit = FunctionPrototypeBind(wasiReturnOnProcExit, this); | ||
| 108 | + returnOnExit = options.returnOnExit; | ||
| 109 | 109 | } | |
| 110 | + if (returnOnExit) | ||
| 111 | + wrap.proc_exit = FunctionPrototypeBind(wasiReturnOnProcExit, this); | ||
| 110 | 112 | ||
| 111 | 113 | this[kSetMemory] = wrap._setMemory; | |
| 112 | 114 | delete wrap._setMemory; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,15 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | ||
| 4 | + function returnOnExitEnvToValue(env) { | ||
| 5 | + const envValue = env.RETURN_ON_EXIT; | ||
| 6 | + if (envValue === undefined) { | ||
| 7 | + return undefined; | ||
| 8 | + } | ||
| 9 | + | ||
| 10 | + return envValue === 'true'; | ||
| 11 | + } | ||
| 12 | + | ||
| 4 | 13 | if (process.argv[2] === 'wasi-child-preview1') { | |
| 5 | 14 | // Test version set to preview1 | |
| 6 | 15 | const assert = require('assert'); | |
@@ -23,6 +32,7 @@ if (process.argv[2] === 'wasi-child-preview1') { | |||
| 23 | 32 | '/sandbox': fixtures.path('wasi'), | |
| 24 | 33 | '/tmp': tmpdir.path, | |
| 25 | 34 | }, | |
| 35 | + returnOnExit: returnOnExitEnvToValue(process.env), | ||
| 26 | 36 | }); | |
| 27 | 37 | ||
| 28 | 38 | // Validate the getImportObject helper | |
@@ -56,6 +66,10 @@ if (process.argv[2] === 'wasi-child-preview1') { | |||
| 56 | 66 | if (options.stdin !== undefined) | |
| 57 | 67 | opts.input = options.stdin; | |
| 58 | 68 | ||
| 69 | + if ('returnOnExit' in options) { | ||
| 70 | + opts.env.RETURN_ON_EXIT = options.returnOnExit; | ||
| 71 | + } | ||
| 72 | + | ||
| 59 | 73 | const child = cp.spawnSync(process.execPath, [ | |
| 60 | 74 | ...args, | |
| 61 | 75 | __filename, | |
@@ -79,7 +93,9 @@ if (process.argv[2] === 'wasi-child-preview1') { | |||
| 79 | 93 | if (!common.isIBMi) { | |
| 80 | 94 | runWASI({ test: 'clock_getres' }); | |
| 81 | 95 | } | |
| 82 | - runWASI({ test: 'exitcode', exitCode: 120 }); | ||
| 96 | + runWASI({ test: 'exitcode' }); | ||
| 97 | + runWASI({ test: 'exitcode', returnOnExit: true }); | ||
| 98 | + runWASI({ test: 'exitcode', exitCode: 120, returnOnExit: false }); | ||
| 83 | 99 | runWASI({ test: 'fd_prestat_get_refresh' }); | |
| 84 | 100 | runWASI({ test: 'freopen', stdout: `hello from input2.txt${checkoutEOL}` }); | |
| 85 | 101 | runWASI({ test: 'ftruncate' }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments