C1: alpha dry run fixes (Ctrl+C in terminal, ignored colour, find singular)
Some checks failed
ci / ci (macos-15) (push) Has been cancelled
ci / ci (ubuntu-24.04) (push) Has been cancelled
ci / ci (windows-2025) (push) Has been cancelled

- Terminal: undo an inherited "ignore Ctrl+C" flag before starting a
  ConPTY shell (lutra_proc::enable_ctrl_c). Lutra started by the lutra
  CLI (CREATE_NEW_PROCESS_GROUP) passed it to every shell, so Ctrl+C
  stopped nothing. Test reruns itself with that flag.
- Engine: an edited .gitignore/.ignore reports TreeChanged for its
  folder, so the tree greys newly ignored files (Add to .gitignore).
- Find: "1 match", "1 file" instead of "1 files".
- docs/alpha-checklist.md: steps corrected after the Windows dry run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-11-02 17:55:58 +01:00
parent 30de747ad6
commit e228d11ef9
11 changed files with 173 additions and 20 deletions

View file

@ -21,6 +21,7 @@ doc = false
windows-sys = { version = "0.61.2", features = [
"Win32_Foundation",
"Win32_Security",
"Win32_System_Console",
"Win32_System_Diagnostics_ToolHelp",
"Win32_System_JobObjects",
"Win32_System_Threading",

View file

@ -35,7 +35,8 @@
//!
//! [`adopt`] (Windows) puts a process started by someone else, the
//! integrated terminal's ConPTY shell, into a kill-on-close job and returns
//! a [`Guard`] that holds it.
//! a [`Guard`] that holds it. [`enable_ctrl_c`] (Windows) undoes an
//! inherited "ignore Ctrl+C" flag before that shell starts.
use std::io;
use std::ops::{Deref, DerefMut};
@ -169,6 +170,18 @@ pub fn adopt(process: std::os::windows::io::RawHandle) -> io::Result<Guard> {
Group::adopt(process).map(|group| Guard { group })
}
/// Undoes an inherited "ignore Ctrl+C" flag (Windows only), so console
/// programs started from now on, such as the integrated terminal's shell
/// and what it runs, get Ctrl+C. Lutra inherits that flag when it is
/// started with `CREATE_NEW_PROCESS_GROUP`, as the `lutra` CLI does.
///
/// # Errors
/// The OS error of `SetConsoleCtrlHandler`.
#[cfg(windows)]
pub fn enable_ctrl_c() -> io::Result<()> {
windows::enable_ctrl_c()
}
#[cfg(windows)]
impl Guard {
/// Terminates every process in the job.

View file

@ -15,8 +15,12 @@
//! [`Group::adopt`] puts a process someone else started (the terminal's
//! ConPTY shell) into a new job by its handle.
//!
//! [`enable_ctrl_c`] undoes an inherited "ignore Ctrl+C" flag
//! (`SetConsoleCtrlHandler(NULL, FALSE)`), so the terminal's shells pass
//! Ctrl+C on to the programs they run.
//!
//! This is the one module in Lutra that allows `unsafe`: the job object,
//! Tool Help and thread APIs are only reachable through FFI. Every call gets
//! Tool Help, thread and console APIs are only reachable through FFI. Every call gets
//! valid arguments by construction: handles come from `CreateJobObjectW`,
//! `CreateToolhelp32Snapshot` or `OpenThread` (owned by an [`OwnedHandle`]
//! right away) or from a live [`std::process::Child`], and the limit and
@ -30,6 +34,7 @@ use std::os::windows::process::CommandExt;
use std::process::Command;
use windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE;
use windows_sys::Win32::System::Console::SetConsoleCtrlHandler;
use windows_sys::Win32::System::Diagnostics::ToolHelp::{
CreateToolhelp32Snapshot, TH32CS_SNAPTHREAD, THREADENTRY32, Thread32First, Thread32Next,
};
@ -45,6 +50,22 @@ use windows_sys::Win32::System::Threading::{
/// The exit code a process killed with its job reports.
const KILLED_EXIT_CODE: u32 = 1;
/// Lets this process, and the console programs it starts from now on,
/// handle Ctrl+C again: `SetConsoleCtrlHandler(NULL, FALSE)`.
///
/// A process started with `CREATE_NEW_PROCESS_GROUP` (the `lutra` CLI
/// starts Lutra that way) ignores Ctrl+C, and its children inherit that.
///
/// # Errors
/// The OS error of `SetConsoleCtrlHandler`.
pub(crate) fn enable_ctrl_c() -> io::Result<()> {
let ok = unsafe { SetConsoleCtrlHandler(None, 0) };
if ok == 0 {
return Err(io::Error::last_os_error());
}
Ok(())
}
/// The job a child runs in. Lutra holds the only handle; closing it (on
/// drop, or when Lutra's process ends) kills every process in the job.
pub(crate) struct Group {