Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9584109
Add a test demonstrating the forking hazards
krassowski Oct 27, 2026
f2042df
Fix pre-commit issue and improve comments
krassowski Oct 27, 2026
5f66dfe
Implement `posix_spawn` helper
krassowski Oct 27, 2026
3a2dd69
Import Mapping and Sequence from collections.abc
krassowski Oct 28, 2026
c45e961
Test more parts of the spawn helper
krassowski Oct 28, 2026
ce81bbf
Do not trust `/dev/fd` outside macOS
krassowski Oct 28, 2026
44dee1e
Fall back to fork when the helper interpreter does not start
krassowski Oct 28, 2026
27918fd
Pass LC_CTYPE from env to the shell unchanged
krassowski Oct 28, 2026
ba53835
Stop waiting for the helper after 30 seconds
krassowski Oct 28, 2026
0c46122
Return file names in helper errors unchanged
krassowski Oct 28, 2026
801c017
Remove the pytest filter for the fork warning
krassowski Oct 28, 2026
f630671
Improve fork fallback and tests
krassowski Oct 28, 2026
2047625
Block SIGINT in the helper until it calls setsid()
krassowski Oct 28, 2026
1f456f4
Close the terminal and kill the helper when an open fails
krassowski Oct 28, 2026
ba43ab7
Report a helper that exits before exec
krassowski Oct 28, 2026
2b22716
Reduce comment repetition and verbosity
krassowski Oct 28, 2026
5d0f887
Minor tests cleanup
krassowski Oct 28, 2026
a568f7b
Check the helper with a real start
krassowski Oct 28, 2026
80a9261
Keep the bytes of cwd and argv in any locale
krassowski Oct 28, 2026
d469044
Ensure the tests run with a new test; clarify comment
krassowski Oct 28, 2026
fee0c62
Move the helper code to a .py file, add `PTYPROCESS_USE_FORK`
krassowski Nov 4, 2026
b78cb82
Address Copilot's review: stop the startup check at the EXEC_TIMEOUT …
krassowski Nov 10, 2026
b0abe03
Keep the terminal open until the helper's error is read
Carreau Nov 13, 2026
d4dc269
Show the elapsed time when a timing assertion fails
Carreau Nov 13, 2026
287ac03
rename _close to _close_all_fds
Carreau Nov 17, 2026
e0442bb
Fix a race on Mac
krassowski Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ JS:
- `terminado/_static/terminado.js`: A lightweight wrapper to set up a
term.js terminal with a websocket.

Starting terminals:

On POSIX systems, terminado starts each terminal from a small Python
helper with `os.posix_spawn()`, so the server does not fork. Terminado
still forks on PyPy, in frozen applications, and when the helper does
not start. To always fork, set `PTYPROCESS_USE_FORK=1` in the
environment of the server.

Local Installation:

> $ pip install -e .[test]
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ timeout = 300
filterwarnings = [
"error",
"module:unclosed <socket.socket:ResourceWarning",
# Spawning a pty while the server has executor threads running warns since
# Python 3.12, and the warning is raised under "error" since Python 3.15
"ignore:This process .* is multi-threaded:DeprecationWarning",
]
# Restore this setting to debug failures
# timeout_method = "thread"
Expand All @@ -110,6 +107,8 @@ exclude_lines = [
[tool.coverage.run]
relative_files = true
source = ["terminado"]
# The helper runs with `python -I -S`, where coverage cannot measure it.
omit = ["*/terminado/_spawn_helper.py"]

[tool.mypy]
files = "terminado"
Expand Down Expand Up @@ -166,6 +165,12 @@ unfixable = [
# N802 Function name `assertIn` should be lowercase
# PT009 Use a regular `assert` instead of unittest-style
"tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "PT009"]
# The helper does not import pathlib or contextlib, because every import adds to the time
# that a terminal takes to open. The helper starts the command with os.execve().
# PTH208 Use `pathlib.Path.iterdir()` instead
# SIM105 Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass`
# S606 Starting a process without a shell
"terminado/_spawn_helper.py" = ["PTH208", "SIM105", "S606"]

[tool.interrogate]
ignore-init-module=true
Expand Down
Loading
Loading