Skip to content

Commit

Permalink
fix(cli.rs): before dev process kill, closes #1626 (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored May 4, 2021
1 parent 2b4e2b7 commit ac2cbcb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/fix-before-dev-command-kill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cli.rs": patch
---

Properly kill `beforeDevCommand` process.
13 changes: 12 additions & 1 deletion tooling/cli.rs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ static BEFORE_DEV: OnceCell<Mutex<Child>> = OnceCell::new();

fn kill_before_dev_process() {
if let Some(child) = BEFORE_DEV.get() {
let _ = child.lock().unwrap().kill();
let mut child = child.lock().unwrap();
#[cfg(windows)]
let _ = Command::new("powershell")
.arg("-Command")
.arg(format!("function Kill-Tree {{ Param([int]$ppid); Get-CimInstance Win32_Process | Where-Object {{ $_.ParentProcessId -eq $ppid }} | ForEach-Object {{ Kill-Tree $_.ProcessId }}; Stop-Process -Id $ppid }}; Kill-Tree {}", child.id()))
.status();
#[cfg(not(windows))]
let _ = Command::new("pkill")
.args(&["-TERM", "-P"])
.arg(child.id().to_string())
.status();
let _ = child.kill();
}
}

Expand Down

0 comments on commit ac2cbcb

Please sign in to comment.