Files
clide/ptyc/Makefile
T
jpmschweitzerandClaude 0412a2284a scaffold ptyc — C PTY-spawn helper (libc only)
One-shot helper that opens a PTY, forks a child, execvp's the given
argv with the slave as stdin/stdout/stderr, and hands the master fd
back to the caller over a unix socket via SCM_RIGHTS. Wire contract
is stdin JSON → stdout JSON + fd transfer per D-005; socket fd
defaults to 3 with PTYC_SOCK_FD override for language runtimes whose
subprocess machinery shuffles the low fd numbers.

Minimal JSON parser (no deps) scoped to the exact accepted shape.
Exec-failure pipe (CLOEXEC) reports child-side errors back without
zombies. Window size applied via TIOCSWINSZ before fork; child
becomes session leader + makes the slave its controlling TTY.

Root Makefile PTYX_PRESENT typo fixed → PTYC_PRESENT, and a
ptyc-test target added alongside ptyc-build / ptyc-clean. Eight
smoke tests pass (happy path, env replacement, cwd, window size,
bad argv, type errors, exec failure, unknown keys).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-21 22:27:20 +02:00

28 lines
465 B
Makefile

# ptyc — PTY-spawn helper for clide.
#
# Single source file, libc only. No configure step. Builds everywhere a
# POSIX-y C compiler + unix sockets exist.
CC ?= cc
CFLAGS ?= -std=c11 -Wall -Wextra -Wpedantic -Werror -O2 -D_FORTIFY_SOURCE=2
LDFLAGS ?=
BIN := bin/ptyc
.PHONY: all
all: $(BIN)
$(BIN): ptyc.c | bin
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
bin:
mkdir -p bin
.PHONY: test
test: $(BIN)
./test_ptyc.sh
.PHONY: clean
clean:
rm -rf bin *.o