mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 13:16:39 +03:00
procinfo: add windows console field. mux: ignore non-console procs
When considering the fg process, we don't want a newly spawned notepad.exe to show as the fg process in a cmd/pwsh pane, as it runs async from the console and isn't attached to it. We can extract the console handle from the process information and use a 0 value handle to indicate win32 apps that are not attached to any console. We cannot compare console handle values directly: without probing deeper into the handle we don't know that two differently valued handles refer to different consoles, because a handle can be duplicated into another with a different numeric value.
This commit is contained in:
parent
0bcd770102
commit
5660942055
@ -780,7 +780,9 @@ impl LocalPane {
|
||||
}
|
||||
|
||||
for child in proc.children.values() {
|
||||
find_youngest(child, youngest);
|
||||
if child.console != 0 {
|
||||
find_youngest(child, youngest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,10 @@ pub struct LocalProcessInfo {
|
||||
pub argv: Vec<String>,
|
||||
pub cwd: PathBuf,
|
||||
pub status: LocalProcessStatus,
|
||||
pub children: HashMap<u32, LocalProcessInfo>,
|
||||
pub start_time: u64,
|
||||
#[cfg(windows)]
|
||||
pub console: u64,
|
||||
pub children: HashMap<u32, LocalProcessInfo>,
|
||||
}
|
||||
luahelper::impl_lua_conversion!(LocalProcessInfo);
|
||||
|
||||
|
@ -86,6 +86,7 @@ fn wstr_to_string(slice: &[u16]) -> String {
|
||||
struct ProcParams {
|
||||
argv: Vec<String>,
|
||||
cwd: PathBuf,
|
||||
console: HANDLE,
|
||||
}
|
||||
|
||||
struct ProcHandle(HANDLE);
|
||||
@ -220,6 +221,7 @@ impl ProcHandle {
|
||||
Some(ProcParams {
|
||||
argv: cmd_line_to_argv(&cmdline),
|
||||
cwd: wstr_to_path(&cwd),
|
||||
console: params.ConsoleHandle,
|
||||
})
|
||||
}
|
||||
|
||||
@ -243,6 +245,7 @@ impl ProcHandle {
|
||||
Some(ProcParams {
|
||||
argv: cmd_line_to_argv(&cmdline),
|
||||
cwd: wstr_to_path(&cwd),
|
||||
console: params.ConsoleHandle as _,
|
||||
})
|
||||
}
|
||||
|
||||
@ -353,6 +356,7 @@ impl LocalProcessInfo {
|
||||
let mut start_time = 0;
|
||||
let mut cwd = PathBuf::new();
|
||||
let mut argv = vec![];
|
||||
let mut console = 0;
|
||||
|
||||
if let Some(proc) = ProcHandle::new(info.th32ProcessID) {
|
||||
if let Some(exe) = proc.executable() {
|
||||
@ -361,6 +365,7 @@ impl LocalProcessInfo {
|
||||
if let Some(params) = proc.get_params() {
|
||||
cwd = params.cwd;
|
||||
argv = params.argv;
|
||||
console = params.console as _;
|
||||
}
|
||||
if let Some(start) = proc.start_time() {
|
||||
start_time = start;
|
||||
@ -377,6 +382,7 @@ impl LocalProcessInfo {
|
||||
start_time,
|
||||
status: LocalProcessStatus::Run,
|
||||
children,
|
||||
console,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user