Skip to content

Spawned process don't trigger close or exit event #4500

Closed
@Geelik

Description

@Geelik

Hi,

When i spawn a process and write in his stdin he will not trigger "close" or "exit" event.

emuObject.currentProcess = spawn(externalCommands[cmd], cmdArgs, {cwd:emuObject.cd});

            emuObject.stdin.pipe(emuObject.currentProcess.stdin);
            emuObject.currentProcess.stdout.on('data', function(data){
                self.emit('createOutput', emuObject, data.toString());
            });

            emuObject.currentProcess.stderr.on('data', function(data){
                self.emit('createError', emuObject, data.toString());
            });

            emuObject.currentProcess.on('exit', function(code, signal){
                console.log('exited process');
            });

            emuObject.currentProcess.on('close', function(code, signal){
                console.log('closed process');
                if(code == 0){
                    emuObject.currentProcess = null;
                    self.emit('createLine', emuObject, emuObject.cd);
                }
                else{
                    emuObject.currentProcess = null;
                    self.emit('createLine', emuObject, emuObject.cd);
                    self.emit('killEmu', emuObject, true);
                }
            });

i tried:

    emuObject.currentProcess.stdin.resume();
    emuObject.currentProcess.stdin.write(cmd + '\n');
    emuObject.currentProcess.stdin.pause();

but it does nothing
I tried too

    emuObject.currentProcess.stdin.write(cmd + '\n');
    emuObject.currentProcess.stdin.end();

but it end the child process instantly.

Just in case it can have something to do with this issue, i'm using nw.js

Any idea?

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