16

Sometimes when my terminal freezes up and it will not let me type. I can not identify any causes, nor how to diagnose. Any suggestions?

Thanks!

GNOME Terminal 2.30.2 on Ubuntu 10.04

  • 2
    usually when the terminal freezes it is caused by another application in the background using too many resources, like the CPU or Disk I/O. If you run top in a terminal, you should be able to locate the problem easily. – RolandiXor Nov 30 '10 at 02:37
  • @roland - sounds like a catch-22, but good advice since sometimes when one terminal is frozen I can open another and it will work. – David LeBauer Nov 30 '10 at 02:38
  • I Know right? :) It is a bit of a catch-22, but it often works for me. – RolandiXor Nov 30 '10 at 02:46

2 Answers2

37

Did you press Ctrl+S by any chance? It's the terminal pause key that stops all output until you press Ctrl-Q to resume.

  • what could be the reason behind providing the option to pause the terminal, just curious to know. – learner Apr 25 '20 at 04:51
  • 3
    Sometimes it's helpful, when an application is printing lots of output non-stop, and you want to make it pause so you can read it before it disappears off screen.

    It's also the same control character used for software flow control, when one device wants to tell the other device to slow down for a bit.

    – Marius Gedminas Apr 25 '20 at 17:34
  • @learner The Control-S opton is a relict from old times up to about the 1980-ies when the computer was operated using a teletype, or teletype-like text-based video terminal. Even worse, the computer output often was concise and cryptic, so pausing was convenient to get some more time to study the messages before these would disappear past the top of the screen – Roland Nov 10 '23 at 15:21
16

A good general way to diagnose mysterious hangs:

  1. open a(nother) terminal, and use ps axo pid,wchan:32,cmd to find the other process id
  2. note the wchan column, which should tell you whether it's stuck in the kernel
  3. run sudo strace -p PID inserting the pid of that process; paste that into a bug report or question

If there's anything aside from just a dash in the wchan column, then the process is in the kernel doing something. Some typical values:

  • futex_wait_queue_me - waiting on a futex for another thread in the same process
  • poll_schedule_timeout - waiting for network or interprocess communication, or just sleeping for a while
  • pipe_wait - reading/writing a pipe

There are thousands of possibilities so I can't list them all. See What is the "Waiting Channel" of a process? for more.

poolie
  • 9,241
  • Very useful for general purpose bug tracking. Can you please update your answer with some extensive description ? What message in wchan column indicates a program that is stuck in the kernel ? – Salih Emin Nov 30 '10 at 13:19
  • Thanks, Salih. Maybe we should have another question about how in general to diagnose hangs? – poolie Nov 30 '10 at 21:42
  • If people are curious about any other wchan values, please add a comment. – poolie Mar 14 '12 at 00:37
  • Any wchan means the process is waiting in the kernel. If it stays there for a long time and for no good reason like listening for network io, then it's stuck. ;) – poolie Dec 11 '15 at 06:08
  • I have do-epoll-wait and do-wait in the wchan column related to .vscode-server which should be fine listening to remote wsl connection. – Timo Jun 20 '21 at 07:45