Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.
Rust agent-skillsclaude-codeclicode-migrationcodexffigolangjavajavascriptmcpmigrationnapiperformanceportingpyo3pythonrewriterubyrusttypescript
test: stop the HTTP front door with SIGTERM so its original stops too (#1242) (#1243)
Bora Ata Türkoğlu02858e82daf3
diff --git a/docs/pitfalls.md b/docs/pitfalls.mdindex d4fb323e..ac39a1c2 100644--- a/docs/pitfalls.md+++ b/docs/pitfalls.md@@ -709,6 +709,12 @@ other tests were starting processes; a child forked during the write still heldwriting, so exec failed. Write a script that a test runs from a separate process (`cp` from a textfile) and never rewrite one that already ran.+**A test stopped a front door with `Child::kill` and its original stayed.** The HTTP front door+runs the original in a process group of its own and stops it when it ends; SIGKILL gives it no+chance to, so every full `cargo test` left three `node server.js` listening. A test that starts a+front door itself stops it with SIGTERM, keeps SIGKILL for one that does not end, and checks with+`ps` that nothing still runs out of its folder.+## Verdicts that could be weakened**A port that answered with the original passed `lift` and `package`.** `lift` checked that the gluediff --git a/tests/obligations_fallbacks_door.rs b/tests/obligations_fallbacks_door.rsindex 16329ab2..f71f4551 100644--- a/tests/obligations_fallbacks_door.rs+++ b/tests/obligations_fallbacks_door.rs@@ -314,11 +314,50 @@ struct HttpDoor {impl Drop for HttpDoor {fn drop(&mut self) {+ // Issue #1242: the front door runs the original in a process group of its own and stops it+ // when it ends. `Child::kill` is SIGKILL, which gives it no chance to: the original then+ // stays, listening. SIGTERM lets it end as it does for a user, and SIGKILL is what is left+ // for a front door that does not.+ #[cfg(unix)]+ {+ let _ = Command::new("kill")+ .args(["-TERM", &self.child.id().to_string()])+ .stderr(Stdio::null())+ .status();+ let asked = Instant::now();+ while asked.elapsed() < Duration::from_secs(10) {+ if matches!(self.child.try_wait(), Ok(Some(_)) | Err(_)) {+ return;+ }+ std::thread::sleep(Duration::from_millis(20));+ }+ }let _ = self.child.kill();let _ = self.child.wait();}}+/// The command lines of the processes still running out of `root`, the test's own folder: an+/// original that its front door left behind is one of them.+#[cfg(unix)]+fn left_running(root: &Path) -> Vec<String> {+ let folder = format!("{}/", root.file_name().unwrap().to_string_lossy());+ let ps = Command::new("ps")+ .args(["-axo", "pid=,command="])+ .output()+ .unwrap();+ assert!(+ ps.status.success(),+ "ps failed: {}",+ String::from_utf8_lossy(&ps.stderr)+ );+ String::from_utf8_lossy(&ps.stdout)+ .lines()+ .filter(|line| line.contains(&folder))+ .map(str::to_string)+ .collect()+}+fn start_http(exe: &Path, root: &Path, journal: Option<&Path>) -> HttpDoor {let port = {let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();@@ -428,6 +467,13 @@ fn an_http_front_door_journals_the_request_and_its_status_and_never_a_header_or_plain.iter().any(|(status, _)| *status >= 400),"the script has refusals: {plain:?}");+ // Issue #1242: each front door is stopped by now, and its original with it.+ #[cfg(unix)]+ assert_eq!(+ left_running(&root),+ Vec::<String>::new(),+ "a stopped front door left its original running"+ );assert!(!leak.exists(),