Skip to content

rp2: Can't send KeyboardInterrupt with os.dupterm() #17732

@sfe-SparkFro

Description

@sfe-SparkFro

Port, board and/or hardware

rp2

MicroPython version

MicroPython v1.25.0 on 2025-04-15; Raspberry Pi Pico 2 W with RP2350

Reproduction

Call os.dupterm() with UART or other compatible stream object:

from machine import UART
import os
os.dupterm(UART(0), 0)

Run some code:

import time
i = 0
while True:
    print(i)
    i += 1
    time.sleep(1)

Expected behaviour

While code is running, pressing Ctrl+C in the USB REPL works as expected:

0
1
2
Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
KeyboardInterrupt:
>>>

Observed behaviour

While code is running, pressing Ctrl+C in the UART REPL fails to send the KeyboardInterrupt and halt execution.

Below, I pressed Ctrl+C a few times in the UART REPL, then once in the USB REPL. It then output extra >>>'s for each time I hit Ctrl+C in the UART REPL, indicating the KeyboardInterrupt's were getting buffered or something?

0
1
2
3
Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
KeyboardInterrupt:
>>>
>>>
>>>
>>>
>>>

Additional Information

Although the provided replication code uses UART, this also happens with a Bluetooth REPL connection and is actually what we need to be fixed. This was just the simplest way to replicate.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy