mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-25 23:04:27 +00:00
Avoid killing Zed when terminating terminal process before process group is set by shell (#52542)
Release Notes: - Fixed a bug where killing a terminal process in the agent panel would sometimes kill Zed itself.
This commit is contained in:
parent
bd5aa7753e
commit
2f762eee4b
1 changed files with 10 additions and 2 deletions
|
|
@ -36,11 +36,19 @@ impl ProcessIdGetter {
|
|||
}
|
||||
|
||||
fn pid(&self) -> Option<Pid> {
|
||||
// Negative pid means error.
|
||||
// Zero pid means no foreground process group is set on the PTY yet.
|
||||
// Avoid killing the current process by returning a zero pid.
|
||||
let pid = unsafe { libc::tcgetpgrp(self.handle) };
|
||||
if pid < 0 {
|
||||
if pid > 0 {
|
||||
return Some(Pid::from_u32(pid as u32));
|
||||
}
|
||||
|
||||
if self.fallback_pid > 0 {
|
||||
return Some(Pid::from_u32(self.fallback_pid));
|
||||
}
|
||||
Some(Pid::from_u32(pid as u32))
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue