15

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

David LeBauer
  • 1,616
  • 5
  • 19
  • 36
  • 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

36

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.

Marius Gedminas
  • 11,161
  • 8
  • 50
  • 54
  • 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](https://en.wikipedia.org/wiki/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
15

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,161
  • 4
  • 38
  • 62
  • 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