Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(upgrade): stop running deno lsp processes on windows before attempting to replace executable #26542

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve to be more reliable
  • Loading branch information
dsherret committed Oct 25, 2024
commit ef439f46307540f472d0a72b36ec098d632035ea
24 changes: 21 additions & 3 deletions cli/tools/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,11 +973,29 @@ fn check_windows_access_denied_error(
#[cfg(windows)]
fn kill_running_deno_lsp_processes() {
// limit this to `deno lsp` invocations to avoid killing important programs someone might be running
let _ = Command::new("powershell")
let is_debug = log::log_enabled!(log::Level::Debug);
let get_pipe = || {
if is_debug {
std::process::Stdio::inherit()
} else {
std::process::Stdio::null()
}
};
let _ = Command::new("powershell.exe")
.args([
"-Command",
"Get-Process | Where-Object { $_.ProcessName -eq 'deno' -and ($_.CommandLine -split ' ')[1] -eq 'lsp' } | Stop-Process -Force",
"-Command",
r#"Get-WmiObject Win32_Process |
Where-Object {
$_.Name -eq 'deno.exe' -and
$_.CommandLine -match '^(?:\"[^\"]+\"|\S+)\s+lsp\b'
} | ForEach-Object {
if ($_.Terminate()) {
Write-Host 'Terminated:' $_.ProcessId
}
}"#,
])
.stdout(get_pipe())
.stderr(get_pipe())
.output();
}

Expand Down
Loading