Spawned Node (.exe) process doesnt catch stderr messages

Lucasvw

So I am having some trouble with Node and spawning processes here..

I am spawning an external exe process as such:

            var writeStream = fs.createWriteStream(logPath);

            writeStream.write(new Date().toString() + " : " + type + " : LOG STARTED ");

            var process = cp.spawn(fileNameExecutable, paramArray, {
                cwd: pathToExecutable
            });


            process.stdout.on('data', function (data) {
                writeStream.write(new Date().toString() + " : " + type + " stdout : " + string);
            });

            var errorLog = "";
            process.stderr.on('data', function (data) {
                errorLog += data;
                writeStream.write(new Date().toString() + " : " + type + " stderr : " + data );
            });

            process.on("exit", function (exitcode) {
                if (exitcode === 1) {
                    done(new Error(errorLog));
                } else {
                    done();
                }
            });

Problem is that this code only catches the stdout of the process for some reason.. Everything which is outputted over stderr doesnt arrive at the listener.

I know there is stderr output because when I am running the same command over commandline and attach

> stdout.txt 2> stderr.txt

to redirect both streams into a textfile, I am getting messages in both my stderr.txt and stdout.txt

Does anybody have any ideas why the stderr listener is not getting these messages in my JS code ?

Lucasvw

Ok, so I finally found the solution..

The application is a QT based C++ app with the following behavior:

Where is located the qDebug qWarning qCritical and qFatal log by default on Qt?

In short: by setting QT_LOGGING_TO_CONSOLE to 1 before node startup it gets logged correctly.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

spawned process in node.js exiting immediately

From Dev

How to detect if a Node spawned process is still running?

From Dev

Node Kue and Child Process - get error from spawned process

From Dev

Node.js - spawned process is generating error "execvp(): No such file or directory"

From Dev

How to replace node.js process with spawned child?

From Dev

How to get the output of a spawned child_process in Node.JS?

From Dev

Node.js can't get output of spawned process

From Dev

Interaction with spawned process in Scala

From Dev

Pass a packed JS file within an asar package to a spawned node child process

From Dev

Pass a packed JS file within an asar package to a spawned node child process

From Dev

Unable to get output from infinitely running Ruby application spawned from Node child process

From Dev

Child process stdout and stderr column sizes in Node.js

From Dev

Child process stdout and stderr column sizes in Node.js

From Dev

node child_process gives valid output in stderr for mongodump

From Dev

Defining stdout and stderr in a child.process in node.js 8

From Dev

Supervisord error "child process was not spawned"

From Dev

mount fails from spawned process

From Dev

Killing a process spawned by another thread

From Dev

killing the master process spawned by an at command

From Dev

Catch result of process from exe (right click context)

From Dev

How can a process be blocking another process (that it spawned)?

From Dev

Mysterious notepad.exe spawned every morning

From Dev

os.kill not working on spawned process

From Dev

Visual Studio Code - Debugging a spawned process

From Dev

Testing captured IO from a spawned process

From Dev

Read stdout of spawned process that is waiting for input

From Dev

What happens to imports when a new process is spawned?

From Dev

saving PID of spawned process within a Makefile

From Dev

Can't send anything to spawned Erlang process

Related Related

  1. 1

    spawned process in node.js exiting immediately

  2. 2

    How to detect if a Node spawned process is still running?

  3. 3

    Node Kue and Child Process - get error from spawned process

  4. 4

    Node.js - spawned process is generating error "execvp(): No such file or directory"

  5. 5

    How to replace node.js process with spawned child?

  6. 6

    How to get the output of a spawned child_process in Node.JS?

  7. 7

    Node.js can't get output of spawned process

  8. 8

    Interaction with spawned process in Scala

  9. 9

    Pass a packed JS file within an asar package to a spawned node child process

  10. 10

    Pass a packed JS file within an asar package to a spawned node child process

  11. 11

    Unable to get output from infinitely running Ruby application spawned from Node child process

  12. 12

    Child process stdout and stderr column sizes in Node.js

  13. 13

    Child process stdout and stderr column sizes in Node.js

  14. 14

    node child_process gives valid output in stderr for mongodump

  15. 15

    Defining stdout and stderr in a child.process in node.js 8

  16. 16

    Supervisord error "child process was not spawned"

  17. 17

    mount fails from spawned process

  18. 18

    Killing a process spawned by another thread

  19. 19

    killing the master process spawned by an at command

  20. 20

    Catch result of process from exe (right click context)

  21. 21

    How can a process be blocking another process (that it spawned)?

  22. 22

    Mysterious notepad.exe spawned every morning

  23. 23

    os.kill not working on spawned process

  24. 24

    Visual Studio Code - Debugging a spawned process

  25. 25

    Testing captured IO from a spawned process

  26. 26

    Read stdout of spawned process that is waiting for input

  27. 27

    What happens to imports when a new process is spawned?

  28. 28

    saving PID of spawned process within a Makefile

  29. 29

    Can't send anything to spawned Erlang process

HotTag

Archive