Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

384
Views
Kill () no elimina el proceso secundario en node.js
const kill = require('tree-kill') . . . function killWorkload() { Logger.log("within kill"); if (global.currentChild) { Logger.log(global.currentChild.pid); try { kill(global.currentChild.pid, 'SIGKILL', (error) => { Logger.log(error); }); } catch (e) { Logger.error("Unable to Kill"+ e); } } Logger.log("Child killed"); } process.on('SIGINT', (exitCode) => { killWorkload(); Logger.log("Aborted"); }); . . . global.currentChild.on('exit', async(exitCode) => { global.currentChild = ""; //Non normal exit, Something went wrong if (exitCode !== 0) { await Logger.logMsg(exitCode, resultPath); //Writes the exitCode to Logger.txt process.exit(); } //Normal exit else { process.exit(); } }

global.currentchild es un 'proceso secundario' generado que es un ejecutable cpp.

 within kill 12380 Child killed Aborted Error: Command failed: taskkill /pid 12380 /T /F ERROR: The process "12380" not found. at ChildProcess.exithandler (child_process.js:390:12) at ChildProcess.emit (events.js:400:28) at maybeClose (internal/child_process.js:1055:16) at Socket.<anonymous> (internal/child_process.js:441:11) at Socket.emit (events.js:400:28) at Pipe.<anonymous> (net.js:675:12) { killed: false, code: 128, signal: null, cmd: 'taskkill /pid 12380 /T /F' }

este es el resultado que obtengo. Kill() tarda en ejecutarse. Incluso intenté poner el bloque de eliminación dentro de una nueva Promise() con await que tampoco funciona.

El flujo que quiero es generar un signo y debería eliminar el proceso secundario y, a su vez, global.currentChild.on('exit') debe ejecutarse y llamar a process.exit() dentro.

Usé esta línea solo para depurar

 Logger.log("Aborted");

Alguien podría ayudarme con esto, ¿qué estoy haciendo mal aquí?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!