neutralinojs / neutralino.js

JavaScript API for Neutralinojs
https://neutralino.js.org/docs/api/overview
MIT License
232 stars 49 forks source link

spawnedProcess event - pid needed! #103

Open ruslanx3m opened 6 months ago

ruslanx3m commented 6 months ago

If I run several processes at the same time, then some of them get the same id (Neutralino-scoped process identifier). Also, there is no process pid in the spawnedProcess event, but it is specified in the release https://github.com/neutralinojs/neutralinojs/releases/tag/v4.6.0

We need PID not ID (useless) !

{
  id: <id>,
  pid: <pid>,
  action: <action>,
  data: <data>
}

but we get only

{
  id: <id>,
  action: <action>,
  data: <data>
}
abhaysinghs772 commented 5 months ago

hey @ruslanx3m could you please share your code snipppet in order reproduce this issue in my local system. although it is working fine for me, i am getting pId in my case. image

ruslanx3m commented 5 months ago

Hi, I need for event to return PID not ID ... ?!

let nodeProc = await Neutralino.os.spawnProcess('node');

Neutralino.events.on('spawnedProcess', (evt) => {  // no PID in evt
    if(nodeProc.id == evt.detail.id) {
        switch(evt.detail.action) {
            case 'stdOut':
                console.log(evt.detail.data); // 10
                break;
            case 'stdErr':
                console.error(evt.detail.data);
                break;
            case 'exit':
                console.log(`Node.js process terminated with exit code: ${evt.detail.data}`);
                break;
        }
    }
});

await Neutralino.os.updateSpawnedProcess(nodeProc.id, 'stdIn', 'console.log(5 + 5);');
await Neutralino.os.updateSpawnedProcess(nodeProc.id, 'stdInEnd');

image

abhaysinghs772 commented 5 months ago

@shalithasuranga, I think this is a bug, Could you please confirm from your end as well?