Skip to content

Consider PTY allocation for non-TTY environments #52

Description

@sadjow

Context

When running iecs exec from environments without a TTY (e.g., Claude Code, Cursor, CI pipelines, or scripted automation), the AWS SSM session drops prematurely for commands that take time to produce output.

This happens because the SSM Session Manager plugin expects a pseudo-terminal to keep the connection alive. Without one, sessions disconnect before longer-running commands finish.

Reproduction

Commands that produce immediate output work fine:

iecs exec --command "echo hello"

Commands that take a few seconds before producing output fail — the session drops before the output arrives:

# Simulating a slow command (e.g., a Rails runner that takes ~5s to boot)
iecs exec --command "sleep 5 && echo done"

Workaround

Wrapping the call in script to allocate a PTY:

script -q /dev/null iecs exec --command "sleep 5 && echo done"

Suggestion

iecs could detect when it's running without a TTY and either:

  1. Automatically allocate a PTY (e.g., via os.Stdin file descriptor check)
  2. Warn the user that the session may be unstable without a TTY
  3. Provide a --pty flag to explicitly request PTY allocation

This would improve the experience when using iecs from AI-powered editors like Claude Code and Cursor, as well as CI pipelines and other non-interactive use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions