Skip to content

No error was thrown when spawn command was existed but non-executable #26852

@chinesedfan

Description

@chinesedfan
  • Version:

10.2.0/11.12.0

  • Platform:

Darwin localhost 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

  • Details:

Suppose we have following test script and file notexe exist in the same folder. But notexe has no executable permission.

const spawn = require('child_process').spawn;
const path = require('path');

function test(name) {
    console.log('===', name);

    try {
        const child = spawn(name);
        console.log('spawn.returned - child.stdin', !!child.stdin);
    } catch (e) {
        console.log('spawn.error', e.message);
    }
}

// always spawn with child.stdin equals true, and crash with ENOENT
test('notexe');  // can't find in PATH
test('/notexe'); // can't find in root folder

// in Node 8.9.0, spawn throws EACCES and no crash
// in Node 10.2.0/11.12.0, spawn throws no error with child.stdin equals false, and crash
test('./notexe');
test(path.resolve(__dirname, './notexe'));

So, why did Node 10+ change spawn behaviors? On purpose or regressions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions