Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
How can I wait for a check to test if a process is running to finish?

I am writing an Electron app. I have this very simple function which at the moment is just returning an empty array:

async GetStuff()
{
   var result:string[] = [];

   var bExists = false;

   var exec = require('child_process').exec;

   exec("tasklist", (err:any, stdout:any, stderr:any) => {
       err = err;
       stderr = stderr;
       bExists = stdout.toLowerCase().indexOf("unixsrv.exe") > -1;
   });

   return result
}

As it is, it correctly reports if a process named "unixsrv.exe" is running or not.

Thing is, the function as it is will first hit the "return result" line and later will hit the "bExists = " line.

How can modify the above so that I do not return until I have the answer as to whether or not the process exists?

More generically: How can I synchronously test whether a process is running or not?

Thanks for any help.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I have found the answer that works for me here:

node.js how to check a process is running by the process name?

It is the answer posted there by Christiaan Maks

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda