Commit 48c3d015 authored by Devon Carew's avatar Devon Carew

fix the stop command

parent 7115ff26
...@@ -835,16 +835,23 @@ class AndroidDevice extends Device { ...@@ -835,16 +835,23 @@ class AndroidDevice extends Device {
runSync([adbPath, 'shell', 'am', 'force-stop', apk.id]); runSync([adbPath, 'shell', 'am', 'force-stop', apk.id]);
// Kill the server // Kill the server
if (Platform.isMacOS) { if (Platform.isMacOS) {
String pid = runSync(['lsof', '-i', ':$_serverPort', '-t']); String pids = runSync(['lsof', '-i', ':$_serverPort', '-t']).trim();
if (pid.isEmpty) { if (pids.isEmpty) {
_logging.fine('No process to kill for port $_serverPort'); _logging.fine('No process to kill for port $_serverPort');
return true; return true;
} }
// Killing a pid with a shell command from within dart is hard,
// so use a library command, but it's still nice to give the // Handle multiple returned pids.
// equivalent command when doing verbose logging. for (String pidString in pids.split('\n')) {
_logging.info('kill $pid'); // Killing a pid with a shell command from within dart is hard, so use a
Process.killPid(int.parse(pid)); // library command, but it's still nice to give the equivalent command
// when doing verbose logging.
_logging.info('kill $pidString');
int pid = int.parse(pidString, onError: (_) => null);
if (pid != null)
Process.killPid(pid);
}
} else if (Platform.isWindows) { } else if (Platform.isWindows) {
//Get list of network processes and split on newline //Get list of network processes and split on newline
List<String> processes = runSync(['netstat.exe','-ano']).split("\r"); List<String> processes = runSync(['netstat.exe','-ano']).split("\r");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment