diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-20 23:08:47 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-20 23:08:47 +0300 |
| commit | 54d3d3b4d4d2638d0e654fa4f3a39c50c341d971 (patch) | |
| tree | 880a2bdc7e203b31d33a2458c6a0c2d91fc864fa /tests/cross_area.rs | |
| parent | 43afaab582fd5e1428c51ecdbf6770d8e3917de6 (diff) | |
test: close pty masters before waiting
Diffstat (limited to 'tests/cross_area.rs')
| -rw-r--r-- | tests/cross_area.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/cross_area.rs b/tests/cross_area.rs index 87e85109..5b051277 100644 --- a/tests/cross_area.rs +++ b/tests/cross_area.rs @@ -30,14 +30,21 @@ fn unique_test_dir() -> PathBuf { } struct SpawnedHerdr { - _master: Box<dyn MasterPty + Send>, + _master: Option<Box<dyn MasterPty + Send>>, child: Box<dyn Child + Send + Sync>, } +impl SpawnedHerdr { + fn close_master(&mut self) { + drop(self._master.take()); + } +} + impl Drop for SpawnedHerdr { fn drop(&mut self) { let pid = self.child.process_id(); let _ = self.child.kill(); + self.close_master(); if let Some(pid) = pid { let deadline = Instant::now() + Duration::from_secs(2); @@ -124,7 +131,7 @@ fn spawn_server_with_path( drop(pair.slave); SpawnedHerdr { - _master: pair.master, + _master: Some(pair.master), child, } } @@ -159,7 +166,7 @@ fn spawn_client_process( drop(pair.slave); SpawnedHerdr { - _master: pair.master, + _master: Some(pair.master), child, } } @@ -1003,6 +1010,8 @@ fn cross_area_server_kill_then_restart_and_reconnect() { let mut thin_client = spawn_client_process(&config_home, &runtime_dir, &api_socket); let mut thin_reader = thin_client ._master + .as_ref() + .expect("thin client master") .try_clone_reader() .expect("clone thin client reader"); @@ -1039,6 +1048,7 @@ fn cross_area_server_kill_then_restart_and_reconnect() { unsafe { libc::kill(server_pid as libc::pid_t, libc::SIGKILL); } + server.close_master(); assert!( wait_for_child_exit(&mut server.child, Duration::from_secs(5)), "server should exit after SIGKILL" |
