summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 16:04:34 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commitffef5a511a14071bd9be9887439a6cb40af3fb92 (patch)
treef0e41e84a1f84e04c13ad931444aa8d96c59cc70 /test
parent4b7ab8a91defb73006d58abd9f6e7cb3d690d669 (diff)
downloadpardes-ffef5a511a14071bd9be9887439a6cb40af3fb92.tar.gz
pardes-ffef5a511a14071bd9be9887439a6cb40af3fb92.zip
A detached session stopped by SIGTERM, SIGINT or SIGHUP unlinks its sockets
The signals' default action ended the process where it stood, leaving pardes-9p-*.sock and pardes-detached-*.sock for the next session to trip on. The detached session now takes them to mean quit: the handler sets a flag and wakes the loop, which leaves as Exit does, through the teardown that unlinks both. fs.py sends each of the three and checks the sockets are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/fs.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/fs.py b/test/fs.py
index b55ad5ab..45c38c2e 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -3,6 +3,7 @@ import contextlib
import fcntl
import json
import os
+import signal
from pathlib import Path
import subprocess
import struct
@@ -424,10 +425,27 @@ def exit_answers(binary):
raise AssertionError("Exit did not quit the editor")
+def signal_cleans_up(binary):
+ """A detached session told to stop by a signal unlinks its sockets."""
+ for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP]:
+ with tempfile.TemporaryDirectory(prefix='pardes-sig-') as directory:
+ root = Path(directory)
+ seen = {}
+ with session(binary, root, 'sig', terminal=seen) as (client, address):
+ detached = root / 'pardes-detached-sig.sock'
+ assert address.exists() and detached.exists()
+ os.kill(seen['pid'], sig)
+ deadline = time.monotonic() + 5
+ while (address.exists() or detached.exists()) and time.monotonic() < deadline:
+ time.sleep(.01)
+ assert not address.exists() and not detached.exists(), (sig, list(root.iterdir()))
+
+
def test(binary, quic=False):
started = time.monotonic()
run_file(binary)
exit_answers(binary)
+ signal_cleans_up(binary)
for options, message in [
(['--fs'], b'no such option'),
(['--fs9'], b'no such option'),