Skip to content

Commit 56a87b1

Browse files
authored
Correctly kill Dartium on Linux (#575)
* correctly kill Dartium on Linux * adding try catch * fix style
1 parent 6c8cc94 commit 56a87b1

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/src/runner/browser/browser.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,22 @@ abstract class Browser {
108108
/// exceptions.
109109
Future close() {
110110
_closed = true;
111-
_process.then((process) => process.kill());
111+
112+
_process.then((process) {
113+
// Dartium has a difficult time being killed on Linux. To ensure it is
114+
// properly closed, find all children processes and kill those first.
115+
try{
116+
if (Platform.isLinux) {
117+
var result = Process.runSync('pgrep', ['-P', '${process.pid}']);
118+
for (var pid in '${result.stdout}'.split('\n')) {
119+
Process.runSync('kill', ['-9', pid]);
120+
}
121+
}
122+
} catch(e) {
123+
print('Failed to kill browser children: $e');
124+
}
125+
process.kill();
126+
});
112127

113128
// Swallow exceptions. The user should explicitly use [onExit] for these.
114129
return onExit.catchError((_) {});

0 commit comments

Comments
 (0)