Skip to content

fix(shell): Use script command to fix pty errors on Termux#91

Open
estape11 wants to merge 1 commit intoNorthernTechHQ:mainfrom
estape11:main
Open

fix(shell): Use script command to fix pty errors on Termux#91
estape11 wants to merge 1 commit intoNorthernTechHQ:mainfrom
estape11:main

Conversation

@estape11
Copy link
Copy Markdown

@estape11 estape11 commented Aug 8, 2025

The pty.Start function was failing in the Termux environment, causing an "input/output error" when trying to read from the pseudo-terminal.

This change wraps the shell command with the script utility, which provides a more robust way to create pseudo-terminals across different environments, resolving the issue on Termux.

The `pty.Start` function was failing in the Termux environment,
causing an "input/output error" when trying to read from the
pseudo-terminal.

This change wraps the shell command with the `script` utility,
which provides a more robust way to create pseudo-terminals
across different environments, resolving the issue on Termux.

Signed-off-by: Esteban Agüero Pérez <esteban.aguero@northern.tech>
@estape11 estape11 requested a review from a team as a code owner August 8, 2025 00:50
Comment on lines +64 to +69
log.Info("using script command to start shell")
cmd_wrapper := exec.Command("script", "-qec", shell, "/dev/null")
cmd_wrapper.SysProcAttr = cmd.SysProcAttr
cmd_wrapper.Dir = cmd.Dir
cmd_wrapper.Env = cmd.Env
cmd = cmd_wrapper
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is discarding the initialization of the cmd above...
On the other hand, could this be solved by a simple config default change?
You could try adding the following to /etc/nt-connect/nt-connect.json:

{
  "ShellCommand": "script",
  "ShellArguments": ["-qec", "/bin/bash", "/dev/null"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants