mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(lsp): use a dedicated thread for the parent process checker (#21869)
Ensures the Deno process is brought down even when the runtime gets hung up on something. Marvin found that the lsp was running without a parent vscode around so this is maybe/probably related.
This commit is contained in:
parent
cd43d2b877
commit
741afc4b94
1 changed files with 7 additions and 10 deletions
|
@ -1,20 +1,17 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::unsync::spawn;
|
use std::time::Duration;
|
||||||
use tokio::time::sleep;
|
|
||||||
use tokio::time::Duration;
|
|
||||||
|
|
||||||
/// Starts a task that will check for the existence of the
|
/// Starts a thread that will check for the existence of the
|
||||||
/// provided process id. Once that process no longer exists
|
/// provided process id. Once that process no longer exists
|
||||||
/// it will terminate the current process.
|
/// it will terminate the current process.
|
||||||
pub fn start(parent_process_id: u32) {
|
pub fn start(parent_process_id: u32) {
|
||||||
spawn(async move {
|
// use a separate thread in case the runtime gets hung up
|
||||||
loop {
|
std::thread::spawn(move || loop {
|
||||||
sleep(Duration::from_secs(30)).await;
|
std::thread::sleep(Duration::from_secs(10));
|
||||||
|
|
||||||
if !is_process_active(parent_process_id) {
|
if !is_process_active(parent_process_id) {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue