mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
recover-stale-client: do not report a reused PID as a leftover
wait_for_exit counted any live PID with the same number as a leftover, so a reused PID produced a misleading "still present after SIGKILL" message. Compare the original start time and use the process state only to include the original process while it is an unreaped zombie.
This commit is contained in:
1 parent
9291d6accd
commit
631a8afe37
2 files changed
+41
-5
No files matched your search
@@ -151,6 +151,30 @@ class RecoverStaleClientTests(unittest.TestCase):
|
||||
self.assertIn('still present after SIGKILL', output)
|
||||
self.assertIn('parent PID(s): 0', output)
|
||||
|
||||
def test_reused_pid_is_not_reported_as_a_leftover(self):
|
||||
folder = self.process(12, 'mldr', [CLIENT], self.client_env())
|
||||
start_ticks = recover_stale_client.process_start_ticks(folder)
|
||||
stat = (folder / 'stat').read_text()
|
||||
fields = stat.rsplit(')', 1)[1].split()
|
||||
fields[19] = str(int(fields[19]) + 100)
|
||||
(folder / 'stat').write_text(stat.rsplit(')', 1)[0] + ') ' + ' '.join(fields) + '\n')
|
||||
leftovers = recover_stale_client.wait_for_exit(
|
||||
self.prefix, {12: start_ticks}, proc_root=self.proc,
|
||||
sleep=lambda _seconds: None)
|
||||
self.assertEqual(leftovers, [])
|
||||
|
||||
def test_unreaped_zombie_is_still_a_leftover(self):
|
||||
folder = self.process(12, 'mldr', [CLIENT], self.client_env())
|
||||
start_ticks = recover_stale_client.process_start_ticks(folder)
|
||||
stat = (folder / 'stat').read_text()
|
||||
fields = stat.rsplit(')', 1)[1].split()
|
||||
fields[0] = 'Z'
|
||||
(folder / 'stat').write_text(stat.rsplit(')', 1)[0] + ') ' + ' '.join(fields) + '\n')
|
||||
leftovers = recover_stale_client.wait_for_exit(
|
||||
self.prefix, {12: start_ticks}, proc_root=self.proc,
|
||||
sleep=lambda _seconds: None)
|
||||
self.assertEqual(leftovers, [12])
|
||||
|
||||
def test_young_client_is_preserved(self):
|
||||
self.process(10, 'darlingserver', ['darlingserver'])
|
||||
self.process(12, 'mldr', [CLIENT], self.client_env(),
|
||||
|
||||
Reference in new issue
Block a user