How to get the process id of a google chrome launched by Flutter WEb?

Viewed 12

How to get the process id of a google chrome launched by Flutter WEB ?

I have another script (NodeJs) launch Flutter Web . something like this:

const child = spawn("flutter run -d chrome --web-port=49430 main.dart")

My goal is to close the chrome browser opened by Flutter

I tried child.kill() but this kills the dart process, not the web browser

I even tried to kill by port using https://www.npmjs.com/package/fkill fkill(":49430")

1 Answers

According to documentation here, you can retrieve process ID of the spawn from the pid argument, such as:

const grep = spawn('grep', ['ssh']);
console.log(`Spawned child pid: ${grep.pid}`);

In your example: child.pid

Related