Bug 398865

Summary: writes to stdout stall after switching to a different screen
Product: [Applications] konsole Reporter: kdebugs
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: REPORTED ---    
Severity: normal CC: kdebugs, kensington
Priority: NOR    
Version: 18.08.1   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description kdebugs 2018-09-20 09:58:38 UTC
Note: this is mostly copied from my Gentoo bugreport at https://bugs.gentoo.org/628996, but I confirmed that it still happens with version 18.08.1

It seems that applications trying to write data to standard output running from a 'konsole' terminal will stall if I switch to another screen (e.g. by pressing Ctrl+Alt+F1).

As a demonstration I ran the following command in konsole:

( while true; do date; dd if=/dev/urandom bs=1k count=1k | od; sleep 1; done ) | tee /tmp/logfile

I left it running for about 5 seconds, than switched to another user for about 10-15 seconds, than back to the original user.

Now the output of 'grep CEST /tmp/logfile' is:

Sat Aug 26 22:07:16 CEST 2017
Sat Aug 26 22:07:17 CEST 2017
Sat Aug 26 22:07:18 CEST 2017
Sat Aug 26 22:07:20 CEST 2017
Sat Aug 26 22:07:21 CEST 2017
Sat Aug 26 22:07:22 CEST 2017
Sat Aug 26 22:07:24 CEST 2017
Sat Aug 26 22:07:38 CEST 2017
Sat Aug 26 22:07:39 CEST 2017
Sat Aug 26 22:07:41 CEST 2017
Sat Aug 26 22:07:42 CEST 2017
Sat Aug 26 22:07:43 CEST 2017

It can be clearly seen that between 22:07:24 and 22:07:38, the 'date' command was not executed. (I assume that The 'dd' command was waiting for I/O as Konsole was not processing writes to stdout.)

I think this is a bug in Konsole because I don't experience this issue with xfce4-terminal.
Comment 1 Egmont Koblinger 2018-09-20 13:24:14 UTC
I can confirm the same behavior on Ubuntu 18.04 (konsole 17.12.3).

According to strace, tee is stuck in a write() call to its stdout (/dev/pts/<number>) (this is the expected behavior if konsole doesn't read the data), and so are od and dd back in the chain as they write() to a clogged pipe (as expected).

Konsole is stuck in a futex(0x..., FUTEX_WAIT_PRIVATE, 0, NULL) call.