Skip to content

Commit 046ef0b

Browse files
rgarciaSayan-
andauthored
extend process spawn to allow allocating a tty, attaching (#96)
using the same approach that `docker exec ...` uses: - allow for allocating a tty when making a process - expose an http endpoint that is hijack-able to do pure tcp stuff `./cmd/shell` contains a proof of concept for what would eventually land in the `kernel` CLI. demo running against the image running in unikraft: https://screen.studio/share/6imUEYCv <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Implements interactive PTY support for spawned processes and an attach/resize workflow, plus a small CLI demo and minor wrapper tweaks. > > - Extends `ProcessSpawnRequest` with `allocate_tty`, `rows`, `cols`; server spawns PTY-backed cmds via `creack/pty`, tracks `ptyFile/isTTY`, and defers pipe readers in PTY mode > - Adds raw attach endpoint `GET /process/{process_id}/attach` (HTTP hijack) and `POST /process/{process_id}/resize`; enforces single active attach and uses poll-based PTY→conn copy; cleans up FDs and retains process status briefly post-exit > - Updates OpenAPI (`openapi.yaml`) and generated client/server (`lib/oapi`) to include PTY fields and `processResize`; adds deps `creack/pty`, `x/sys`, `x/term` > - New `cmd/shell` PoC: spawns `/bin/bash` with TTY, hijacks attach over TCP/TLS, resizes on `SIGWINCH` > - Wrapper scripts: ensure/export a sane `HOSTNAME` early in headful/headless images > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7d47214. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Sayan <[email protected]>
1 parent 2ecdeeb commit 046ef0b

File tree

9 files changed

+1057
-167
lines changed

9 files changed

+1057
-167
lines changed

images/chromium-headful/wrapper.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ if [[ -z "${WITHDOCKER:-}" ]]; then
3333
disable_scale_to_zero
3434
fi
3535

36+
# -----------------------------------------------------------------------------
37+
# Ensure a sensible hostname ---------------------------------------------------
38+
# -----------------------------------------------------------------------------
39+
# Some environments boot with an empty or \"(none)\" hostname which shows up in
40+
# prompts. Best-effort set a friendly hostname early so services inherit it.
41+
if h=$(cat /proc/sys/kernel/hostname 2>/dev/null); then
42+
if [ -z "$h" ] || [ "$h" = "(none)" ]; then
43+
if command -v hostname >/dev/null 2>&1; then
44+
hostname kernel-vm 2>/dev/null || true
45+
fi
46+
echo -n "kernel-vm" > /proc/sys/kernel/hostname 2>/dev/null || true
47+
fi
48+
fi
49+
# Also export HOSTNAME so shells pick it up immediately.
50+
export HOSTNAME="${HOSTNAME:-kernel-vm}"
51+
3652
# -----------------------------------------------------------------------------
3753
# House-keeping for the unprivileged "kernel" user --------------------------------
3854
# Some Chromium subsystems want to create files under $HOME (NSS cert DB, dconf

images/chromium-headless/image/wrapper.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ if [[ -z "${WITHDOCKER:-}" ]]; then
3030
disable_scale_to_zero
3131
fi
3232

33+
# -----------------------------------------------------------------------------
34+
# Ensure a sensible hostname ---------------------------------------------------
35+
# -----------------------------------------------------------------------------
36+
if h=$(cat /proc/sys/kernel/hostname 2>/dev/null); then
37+
if [ -z "$h" ] || [ "$h" = "(none)" ]; then
38+
if command -v hostname >/dev/null 2>&1; then
39+
hostname kernel-vm 2>/dev/null || true
40+
fi
41+
echo -n "kernel-vm" > /proc/sys/kernel/hostname 2>/dev/null || true
42+
fi
43+
fi
44+
export HOSTNAME="${HOSTNAME:-kernel-vm}"
45+
3346
# if CHROMIUM_FLAGS is not set, default to the flags used in playwright_stealth
3447
if [ -z "${CHROMIUM_FLAGS:-}" ]; then
3548
CHROMIUM_FLAGS="--accept-lang=en-US,en \

0 commit comments

Comments
 (0)