mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 08:15:41 -08:00
Run the quit cleanup on a plain kill, Ctrl+C and a closing terminal
AI Assisted
This commit is contained in:
1 parent
6a93395148
commit
8c028c1ce0
7 files changed
+458
-3
No files matched your search
@@ -120,6 +120,13 @@ fn node_command(console_dir: &Path) -> Command {
|
||||
use std::os::windows::process::CommandExt;
|
||||
command.creation_flags(0x08000000); // CREATE_NO_WINDOW
|
||||
}
|
||||
// Ctrl+C and a closing terminal signal the app's whole process group: a stop running there
|
||||
// would end before it stopped its console.
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::process::CommandExt;
|
||||
command.process_group(0);
|
||||
}
|
||||
command
|
||||
}
|
||||
|
||||
@@ -895,6 +902,25 @@ mod tests {
|
||||
assert_eq!(*stopped.lock().unwrap(), vec!["s1"]);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_console_call_runs_in_a_process_group_of_its_own() {
|
||||
// Ctrl+C and a closing terminal signal the app's whole group: a stop
|
||||
// already running there ended before it stopped its console.
|
||||
let console = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../src/web-console");
|
||||
let mut child = node_command(&console)
|
||||
.arg("help")
|
||||
.stdout(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::null())
|
||||
.spawn()
|
||||
.expect("node starts");
|
||||
let pid = child.id() as i32;
|
||||
// SAFETY: getpgid only reads; the child is not waited for yet, so its id is its own.
|
||||
let group = unsafe { libc::getpgid(pid) };
|
||||
let _ = child.wait();
|
||||
assert_eq!(group, pid);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_apps_stop_calls_pass_force() {
|
||||
let args = stop_args("20261101-120000-abcdef");
|
||||
|
||||
Reference in new issue
Block a user