V
V
vasyok2282021-11-05 15:00:03
Node.js
vasyok228, 2021-11-05 15:00:03

How to use Child process to track a program that starts another program?

Hello. I have a console .exe that launches the main application, and closes after that.

let child = child_process.fork('run.exe',  ['--username',  this.userName])

    child.stdout.on('data', (data) => {
        console.log(`stdout: ${data}`);
    });
    
    child.stderr.on('data', (data) => {
        console.log(`stderr: ${data}`);
    });
    
    child.on('close', (code) => {
        console.log(`child process exited with code ${code}`);
    });


The first program starts the main program. The problem is that I need to track when the main program starts and when the user closes it.
Please help, I beg you, I've tried everything. Thank you in advance)

Addition:
There is application A and application B.
1. Application A starts B
2. According to the scenario, application A ends (in my case it closes as needed)
3. We need to track the event when application B started
4. We need to track the event when the application closed B

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question