Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

child_process: define EACCES as a runtime error #19294

Closed
wants to merge 1 commit into from

Conversation

gireeshpunathil
Copy link
Member

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Access permission on the target child is currently thrown as an exception. Bring this under the runtime error definition, much like ENOENT and friends.

Fixes: nodejs/help#990

#cat 990.js

require('child_process').spawn(process.argv[2]).on('error', (e) => console.log(e.code))

#node 990.js ./a.out
ENOENT
#touch a.out
#l a.out
-rw-r--r-- 1 gireesh staff 0 Mar 12 13:41 a.out

#node 990.js ./a.out

internal/child_process.js:323
    throw errnoException(err, 'spawn');
    ^

Error: spawn EACCES
    at _errnoException (util.js:1022:11)
    at ChildProcess.spawn (internal/child_process.js:323:11)
    at Object.exports.spawn (child_process.js:502:9)
    at Object.<anonymous> (/users/gireesh/990.js:1:88)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)

while the the definition of runtime errors can be arguable (anything after fork vs. anything after the exec), EACCES belongs to the same group of ENOENT, by all means.

With this fix:
#node 990.js ./a.out
EACCES

Access permission on the target child is currently thrown
as an exception. Bring this under the runtime error definition,
much like ENOENT and friends.

Fixes: nodejs/help#990
@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Mar 12, 2018
@gireeshpunathil
Copy link
Member Author

gireeshpunathil added a commit that referenced this pull request Mar 15, 2018
Access permission on the target child is currently thrown
as an exception. Bring this under the runtime error definition,
much like ENOENT and friends.

PR-URL: #19294
Fixes: nodejs/help#990
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Prince John Wesley <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@gireeshpunathil
Copy link
Member Author

landed as 11b6c0d , thanks.

@targos
Copy link
Member

targos commented Mar 17, 2018

semver-patch or major?

@gireeshpunathil
Copy link
Member Author

@targos - It changes the external behavior, I don't know how to classify it though.

[ An executable file that has come for launch through child_process.spawn* / exec* family of functions, and the current user does not have execute permission on it, will throw exception prior to this PR. With this, it will now be contained in the child_process handles' error handler. ]

@bnoordhuis bnoordhuis added the semver-major PRs that contain breaking changes and should be released in the next major version. label Mar 18, 2018
@bnoordhuis
Copy link
Member

I've conservatively tagged this semver-major.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spawn error doesn't utilize event handlers
8 participants