terminate screen monitoring serial port

53,926

Solution 1

Use the screen quit command (normally ctrl-A \).

Solution 2

I run all my terminals inside a screen, and also sometimes use screen to connect to serial. If you screen /dev/ttyUSB0 inside screen, you'll just get a new window in your current session, not a new child screen.

In this case, press Ctrl-A k to kill only the current window rather than the entire screen process and your other windows with it. This is the kill window command.

Solution 3

Though aecolley's answer usually works then it did not work for me (could be because of Icelandic keyboard and Icelandic locale, but somehow doubt it). When in that situation then you can go to a different console and execute screen -ls and take note of the screen session number, the output should be something like this:

There is a screen on:
            6254.tty2.hostname           (Attached)
1 Socket in /var/run/screen/S-root

The screen session number her is then 6254.

Then you can issue the following command to close that screen session: screen -X -S 6254 quit

Solution 4

For me the issue turned out to be that I had inadvertently logged out of the Linux user account, and not the system I was controlling through the serial port. Once I logged back in, all of the normal screen commands such as Ctrl+a, k began working again.

Beyond that, if you can open a new screen window (Ctrl+a, c), another TTY (Ctrl+Alt+F1..12, or an SSH session, then you can run pkill screen or kill <PID of screen>.

Share:
53,926

Related videos on Youtube

Walrus the Cat
Author by

Walrus the Cat

Updated on September 18, 2022

Comments

  • Walrus the Cat
    Walrus the Cat almost 2 years

    I am using screen /dev/tty-MyDevice to look at traffic on my serial port.

    Pressing Ctrl+D does not cause the screen to terminate.

    What I have to do in order to terminate it?

  • Walrus the Cat
    Walrus the Cat over 9 years
    Ctrl+a Ctrl+-, yields a blank screen, Ctrl+a Ctrl+c yields a new screen, which Ctrl+D then is able to exit like all other screens I've encountered before this.
  • user2578106
    user2578106 over 9 years
    Oops, markdown turned my "ctrl-\" into "ctrl-". Fixed.
  • niels
    niels almost 8 years
    It worked as Ctrl-a \ (that is Ctrl-a and then plain \ without ctrl). Strange that the link provided includes a Ctrl for the \.
  • maxschlepzig
    maxschlepzig over 6 years
    This kind of works, but when connecting to a qemu serial pty this really kills it. That means I can't reconnect to it after that. With picocom, I can easily terminate the serial connection and reconnect later.
  • Cameron Tacklind
    Cameron Tacklind almost 3 years
    CTRL-A k y Is better because it doesn't "quit" all of screen, just "kills" the current tab, which may or may not be the last tab.