The stop command doesn't kill the dev server (vibe-kanban 3b4e5e08)

I notice when the client tries to use the stop command, it doesn't always stop the dev server that's running
This commit is contained in:
Louis Knight-Webb
2025-10-31 17:18:42 +00:00
parent 3ca5218538
commit afd78b614f
4 changed files with 53 additions and 9 deletions

View File

@@ -154,9 +154,28 @@ impl Manager {
c.arg("/C").arg(&command);
c
} else {
let mut c = Command::new("sh");
c.arg("-c").arg(&command);
c
#[cfg(unix)]
{
let mut c = Command::new("sh");
c.arg("-c").arg(&command);
unsafe {
#[allow(unused_imports)]
use std::os::unix::process::CommandExt;
c.pre_exec(|| {
if libc::setsid() == -1 {
return Err(std::io::Error::last_os_error());
}
Ok(())
});
}
c
}
#[cfg(not(unix))]
{
let mut c = Command::new("sh");
c.arg("-c").arg(&command);
c
}
};
cmd.stdout(std::process::Stdio::piped());
cmd.stderr(std::process::Stdio::piped());

View File

@@ -84,12 +84,35 @@ impl ServerEntry {
pub async fn stop(&mut self) -> anyhow::Result<()> {
if let ProcessState::Running(child) = &mut self.state {
child.kill().await?;
match timeout(Duration::from_secs(5), child.wait()).await {
Ok(Ok(_)) => {},
Ok(Err(e)) => return Err(e.into()),
Err(_) => anyhow::bail!("Timeout waiting for process to exit"),
#[cfg(unix)]
{
if let Some(pid) = child.id() {
let pgid = -(pid as i32);
unsafe {
libc::kill(pgid, libc::SIGTERM);
}
}
if timeout(Duration::from_secs(5), child.wait()).await.is_err() {
if let Some(pid) = child.id() {
let pgid = -(pid as i32);
unsafe {
libc::kill(pgid, libc::SIGKILL);
}
}
let _ = timeout(Duration::from_secs(2), child.wait()).await;
}
}
#[cfg(windows)]
{
if let Some(pid) = child.id() {
let _ = tokio::process::Command::new("taskkill")
.args(["/PID", &pid.to_string(), "/T", "/F"])
.status()
.await;
}
let _ = timeout(Duration::from_secs(5), child.wait()).await;
}
self.state = ProcessState::Exited {