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

340
Views
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 answers
Answer question

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 Report
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!