Child_process.fork()


#1

Hi. I have created a module to fork new node instances. When I run it in the cmd it all works fine. Then I try integrate it in my electron app, but the child.js get never executed.

//child-master.js
const cp = [];

childResize(createChildProcess(2));

function createChildProcess(num) {
    if(num <= 0) {
        return cp;
    } else {
        let cf = fork('./resize.js', [], {cwd : __dirname});
        //also tested with: let cf = fork('./resize.js', [], {env: {"ATOM_SHELL_INTERNAL_RUN_AS_NODE":"0", cwd : __dirname});
        cp.push(cf);
        num -= 1;
        return createChildProcess(num);
    }
}

function childResize(list) {
   if(list.length <=0) {
        return true;
    } else {
        const child = list.shift();

         child.on('message', function (data) {  
                if (!temp_path.length) {
                    process.kill(data);
                } else {
                    child.send(temp_path.shift());  
                }
            });

            child.send(temp_path.shift());  

            setTimeout(function() {
                childResize(list);
            }, 1000);      
    }
}

//child.js
process.on('message', function (p) {
// Only put one console statement for simplicity
console.log(p); 
//In electron this is never print to my console
}

In the DevTools I see the child-processes but they have props like 'spawnfile: /pathTo/electron.exe.
What does this mean.