Skip to content

Bug: sudo commands hang process indefinitely with no feedback #1694

@thehighnotes

Description

@thehighnotes

Description

When the LLM generates a command that triggers a [sudo] password for <user> prompt, the subprocess hangs indefinitely waiting for password input that can never arrive. OI uses subprocess.Popen with stdin=subprocess.PIPE — there is no terminal for password entry. The process blocks until the execution timeout fires (default 120s), with no indication of what went wrong.

Steps to reproduce

  1. Start OI with auto_run = True (or approve when prompted)
  2. Ask it to do something that requires root, e.g. "check the systemd journal for errors"
  3. The LLM generates sudo journalctl -xe
  4. OI hangs for ~120 seconds with no output
  5. Eventually times out with a generic error

Root cause

handle_stream_output() in subprocess_language.py reads lines via iter(stream.readline, "") and checks for KeyboardInterrupt, active line markers, and end-of-execution markers — but has no detection for sudo password prompts. The [sudo] password for message arrives on stderr, gets queued as regular output, and the process continues blocking on stdin.

Suggested fix

Detect the sudo prompt pattern in the output stream and immediately signal completion with a clear message:

  def handle_stream_output(self, stream, is_error_stream):
      try:
          for line in iter(stream.readline, ""):
              ...
              line = self.line_postprocessor(line)

              if line is None:
                  continue

+             if "[sudo] password for" in line:
+                 self.output_queue.put(
+                     {
+                         "type": "console",
+                         "format": "output",
+                         "content": "[sudo detected — command requires elevated "
+                                    "privileges. Run it manually.]\n",
+                     }
+                 )
+                 self.done.set()
+                 return

              if self.detect_active_line(line):
                  ...

Since the subprocess uses pipes (not a PTY), we cannot send Ctrl+C to cancel the sudo prompt. But self.done.set() causes run() to stop waiting and return. The blocked subprocess is cleaned up when terminate() is called on the next execution or OI exit.

Environment

  • open-interpreter 0.4.3
  • Python 3.10, Linux (ARM64)
  • Ollama backend, bash shell execution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions