Skip to content
This repository was archived by the owner on Jul 31, 2020. It is now read-only.
This repository was archived by the owner on Jul 31, 2020. It is now read-only.

Process hangs because of unclosed unnamed pipe. #1

@aa6

Description

@aa6

Everything runs perfectly except one thing: pipe's output stream doesn't get closed when pipe's input stream is closed. And that causes the program to run forever until it's closed manually by Ctrl+C. Probably the module must watch for input to close and then close the output but I'm not sure because calling dev_fd_pipe_out.close() on dev_fd_pipe_in closing doesn't helps the situation.

[ fs, loole, child_process ] = [
    require("fs"), require("loole"), require("child_process")
]

loole.createPipe().then(function(fds)
{
    var cp1 = child_process.spawn('echo', ['TEST','STRING'])
    var dev_fd_pipe_in = fs.createWriteStream(`/dev/fd/${fds[1]}`)
    var dev_fd_pipe_out = fs.createReadStream(`/dev/fd/${fds[0]}`)
    cp1.stdout.pipe(dev_fd_pipe_in)
    dev_fd_pipe_out.pipe(process.stdout)

    cp1.stdout.on("close",function()
    {
        console.log("cp1.stdout closed")
    })
    dev_fd_pipe_in.on("close",function()
    {
        console.log("dev_fd_pipe_in closed")
    })
    dev_fd_pipe_out.on("close",function()
    {
        console.log("dev_fd_pipe_out closed")
    })
    process.stdout.on("close",function()
    {
        console.log("process.stdout closed")
    })
})

Prints:

$ node 3.js 
cp1.stdout closed
TEST STRING
dev_fd_pipe_in closed
^C

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions