| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 334a3ac commit 90e12f2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -174,19 +174,18 @@ node:internal/child_process:388 | |||
| 174 | 174 | ^ | |
| 175 | 175 | Error: Access to this API has been restricted | |
| 176 | 176 | at ChildProcess.spawn (node:internal/child_process:388:28) | |
| 177 | - at Object.spawn (node:child_process:723:9) | ||
| 178 | - at Object.<anonymous> (/home/index.js:3:14) | ||
| 179 | - at Module._compile (node:internal/modules/cjs/loader:1120:14) | ||
| 180 | - at Module._extensions..js (node:internal/modules/cjs/loader:1174:10) | ||
| 181 | - at Module.load (node:internal/modules/cjs/loader:998:32) | ||
| 182 | - at Module._load (node:internal/modules/cjs/loader:839:12) | ||
| 183 | - at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) | ||
| 184 | 177 | at node:internal/main/run_main_module:17:47 { | |
| 185 | 178 | code: 'ERR_ACCESS_DENIED', | |
| 186 | 179 | permission: 'ChildProcess' | |
| 187 | 180 | } | |
| 188 | 181 | ``` | |
| 189 | 182 | ||
| 183 | + Unlike `child_process.spawn`, the `child_process.fork` API copies the execution | ||
| 184 | + arguments from the parent process. This means that if you start Node.js with the | ||
| 185 | + Permission Model enabled and include the `--allow-child-process` flag, calling | ||
| 186 | + `child_process.fork()` will propagate all Permission Model flags to the child | ||
| 187 | + process. | ||
| 188 | + | ||
| 190 | 189 | ### `--allow-fs-read` | |
| 191 | 190 | ||
| 192 | 191 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,8 +5,15 @@ const common = require('../common'); | |||
| 5 | 5 | common.skipIfWorker(); | |
| 6 | 6 | const assert = require('assert'); | |
| 7 | 7 | const childProcess = require('child_process'); | |
| 8 | + const fs = require('fs'); | ||
| 8 | 9 | ||
| 9 | 10 | if (process.argv[2] === 'child') { | |
| 11 | + assert.throws(() => { | ||
| 12 | + fs.writeFileSync(__filename, 'should not write'); | ||
| 13 | + }, common.expectsError({ | ||
| 14 | + code: 'ERR_ACCESS_DENIED', | ||
| 15 | + permission: 'FileSystemWrite', | ||
| 16 | + })); | ||
| 10 | 17 | process.exit(0); | |
| 11 | 18 | } | |
| 12 | 19 | ||
@@ -21,6 +28,7 @@ if (process.argv[2] === 'child') { | |||
| 21 | 28 | // doesNotThrow | |
| 22 | 29 | childProcess.spawnSync(process.execPath, ['--version']); | |
| 23 | 30 | childProcess.execSync(...common.escapePOSIXShell`"${process.execPath}" --version`); | |
| 24 | - childProcess.fork(__filename, ['child']); | ||
| 31 | + const child = childProcess.fork(__filename, ['child']); | ||
| 32 | + child.on('close', common.mustCall()); | ||
| 25 | 33 | childProcess.execFileSync(process.execPath, ['--version']); | |
| 26 | 34 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments