Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

child_process.fork() and read from parent process.stdin causes 100% CPU usage #6271

@avz

Description

@avz

This simple script causes 100% CPU usage by parent process after reaching stdin's EOF:

if(process.argv[2] === 'child') {
    console.log('child');

    setInterval(function() {}, 1000); // just sleep
} else {
    console.log('parent');

    process.stdin.on('readable', function() {
        process.stdin.read(); // read stdin until EOF
    });

    require('child_process').fork(__filename, ['child']);
}
% echo 1 | node bug.js

Checked on v0.10.12 (arch and ubuntu), v0.10.17 (arch and ubuntu) and v0.10.19 (arch)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions