Skip to content

Commit

Permalink
Merge pull request #1 from unta1337/feat/win-fix-spawn-cmd
Browse files Browse the repository at this point in the history
Fix `spawn_cmd_background` for windows.
  • Loading branch information
Bubbler-4 authored Jul 3, 2024
2 parents 3000006 + 993f9b6 commit 7591f79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/infra/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ impl Browser {
pub(crate) fn quit(self) -> anyhow::Result<()> {
with_async_runtime(async {
self.webdriver.quit().await?;
run_silent("kill $(pidof geckodriver)").ok();
if cfg!(target_os = "windows") {
run_silent("for /f tokens^=2 %a in ('tasklist ^| findstr geckodriver') do @taskkill /PID %a /F").ok();
} else {
run_silent("kill $(pidof geckodriver)").ok();
}
Ok(())
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/infra/subprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn spawn_cmd(cmd: &str) -> Command {
pub(crate) fn spawn_cmd_background(cmd: &str) -> Command {
if cfg!(target_os = "windows") {
let mut command = Command::new("cmd");
let cmd = format!("START /B \"\" {}", cmd);
let cmd = format!("START /B {}", cmd);
command.arg("/C").arg(&cmd);
command
} else {
Expand Down

0 comments on commit 7591f79

Please sign in to comment.