Skip to content

Commit 1f06f80

Browse files
committed
fix: use python3 pty.spawn fallback instead of script command
script fails with 'tcgetattr/ioctl: Operation not supported on socket' when stdin is a pipe. Python's pty.spawn handles piped I/O correctly.
1 parent 0cbfbfd commit 1f06f80

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

apps/agent/src/commands/expose.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,8 @@ export async function exposeCommand(target: string, options: ExposeOptions): Pro
408408
});
409409
} catch {
410410
const { spawn: spawnChild } = await import('child_process');
411-
const isLinux = process.platform === 'linux';
412-
const args = isLinux ? ['-qc', shell, '/dev/null'] : ['-q', '/dev/null', shell];
413-
const child = spawnChild('script', args, {
411+
const pyScript = `import pty,os;pty.spawn([os.environ.get("SHELL","/bin/bash"),"-l"])`;
412+
const child = spawnChild('python3', ['-c', pyScript], {
414413
stdio: 'pipe',
415414
env: { ...process.env, TERM: 'xterm-256color' },
416415
cwd: process.env.HOME || '/',

apps/agent/src/commands/up.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,8 @@ function connectToHub(config: AgentConfig): Socket {
401401
});
402402
} catch {
403403
const { spawn: spawnChild } = await import('child_process');
404-
const isLinux = process.platform === 'linux';
405-
const args = isLinux ? ['-qc', shell, '/dev/null'] : ['-q', '/dev/null', shell];
406-
const child = spawnChild('script', args, {
404+
const pyScript = `import pty,os;pty.spawn([os.environ.get("SHELL","/bin/bash"),"-l"])`;
405+
const child = spawnChild('python3', ['-c', pyScript], {
407406
stdio: 'pipe',
408407
env: { ...process.env, TERM: 'xterm-256color' },
409408
cwd: process.env.HOME || '/',

0 commit comments

Comments
 (0)