You are not logged in.

#1 2017-08-09 05:43:01

jkovacevic
Member
Registered: 2017-02-07
Posts: 10

[SOLVED] Terminal hangs after command is completed?

Hi,

On random occasions my terminal will hang after command completes. There is no pattern, but if I would have to approximate it happens every 10th command.
This started to occur after I fully upgraded my system.

e.g. after inserting command:

gpg --keyserver keys.gnupg.net --recv-keys 8F0871F202119294

or

python a.py

the command would execute but the terminal would hang and it would require me to press control+C in order to continue (or wait for 10-20 seconds).
The terminal does not freeze - it seems that it is waiting for something. I am certain that command does complete; for example if last line of code in my a.py script outputs a file, the file will be created, but terminal would still hang.

I don't know where to start debugging or what could cause those issues.

This is output of uname -a, I will gladly provide any additional information.

Linux janko-pc 4.12.4-1-ARCH #1 SMP PREEMPT Fri Jul 28 18:54:18 UTC 2017 x86_64 GNU/Linux

The terminal I am using is Terminator. (1.91-5)

Last edited by jkovacevic (2017-08-09 08:31:48)

Offline

#2 2017-08-09 06:13:59

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 72,784

Re: [SOLVED] Terminal hangs after command is completed?

Which shell (bash, zsh, ...)?
What happens with input to the "hanging" terminal? (direct output, or later or not at all?)
Does simply pressing "Enter" "unfreeze" the teminal as well? (or entering eg. ls)

Online

#3 2017-08-09 06:49:39

ayekat
Member
Registered: 2011-01-17
Posts: 1,631

Re: [SOLVED] Terminal hangs after command is completed?

When a command hangs, attach strace to the process to see what it's waiting for.

This is an example of me running cat in one terminal, then attaching to it in another:

$ pgrep -a cat
28796 cat
$ sudo strace -p 28796
strace: Process 28796 attached
read(0, 

Here I can see that it remains "blocked" on the read system call (which makes sense, because it waits for input on stdin).


pkgshackscfgblag

Offline

#4 2017-08-09 07:18:17

jkovacevic
Member
Registered: 2017-02-07
Posts: 10

Re: [SOLVED] Terminal hangs after command is completed?

seth wrote:

Which shell (bash, zsh, ...)?
What happens with input to the "hanging" terminal? (direct output, or later or not at all?)
Does simply pressing "Enter" "unfreeze" the teminal as well? (or entering eg. ls)

This is how my shell (zsh) looks like when before entering any command:

jk@janko-pc /tmp >

When I enter command, wait for it to complete and my shell hangs, pressing enter just positions my cursor to blank newline - I will not get input as above.
I should test whether entering ls command will get executed after my shell unfreezes - but I cannot replicate the bug.

ayekat wrote:

When a command hangs, attach strace to the process to see what it's waiting for.

This is an example of me running cat in one terminal, then attaching to it in another:

$ pgrep -a cat
28796 cat
$ sudo strace -p 28796
strace: Process 28796 attached
read(0, 

Here I can see that it remains "blocked" on the read system call (which makes sense, because it waits for input on stdin).

Thank you, this is useful. When I manage to freeze my terminal again I will experiment with this.

Offline

#5 2017-08-09 07:22:12

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Terminal hangs after command is completed?

My money is on Oh-My-Zshit.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2017-08-09 07:49:58

jkovacevic
Member
Registered: 2017-02-07
Posts: 10

Re: [SOLVED] Terminal hangs after command is completed?

jasonwryan wrote:

My money is on Oh-My-Zshit.

I will try and reinstall it. Are there any better alternatives with out of the box autocompletion?
By the way I managed to replicate it. I believe it has a chance to occurs when I execute never executed command?

I am trying to record video of it, but catching it is so random.

Offline

#7 2017-08-09 07:57:40

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Terminal hangs after command is completed?

+1 for removing OMZ, it is well known to be buggy code.

Vanilla zsh has out of the box autocompletion.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#8 2017-08-09 07:57:40

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Terminal hangs after command is completed?

Anything is a better alternative than that steaming pile of crap.

Remove it and see if that fixes your issue.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#9 2017-08-09 07:58:47

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 72,784

Re: [SOLVED] Terminal hangs after command is completed?

@Jason, why do you think I've asked for the shell ;-)

@jkovacevic, zsh does autocompletion by itself - you don't need OMZ at all. If  you want a useful pre-config, try the grml-zsh-config package, but you should familarize yourself with the shell settings/features on top of this (if you intend intense usage of the textshell)

Online

#10 2017-08-09 08:21:21

jkovacevic
Member
Registered: 2017-02-07
Posts: 10

Re: [SOLVED] Terminal hangs after command is completed?

Thank you all, removing OMZ and installing zsh with grml-zsh-config fixed the issue! Thread can be closed.

Offline

#11 2017-08-09 08:30:35

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Terminal hangs after command is completed?

Threads don't get closed, it's up to you to mark it as [SOLVED]...

https://wiki.archlinux.org/index.php/Co … ow_to_post


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

Board footer

Powered by FluxBB