Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15161

Re: background, pipeline, hang

From Mike Jonkmans <bashbug@jonkmans.nl>
Newsgroups gnu.bash.bug
Subject Re: background, pipeline, hang
Date 2019-07-13 11:55 +0200
Message-ID <mailman.1137.1563011716.2688.bug-bash@gnu.org> (permalink)
References <20190712140057.7F34B12552B@sint.jonkmans.nl> <6c7c3315-d319-d8bd-dfcc-962f9b9ce80a@case.edu> <20190713095508.GB21798@sint.jonkmans.nl>

Show all headers | View raw


On Fri, Jul 12, 2019 at 02:26:52PM -0400, Chet Ramey wrote:
> Date: Fri, 12 Jul 2019 14:26:52 -0400
> From: Chet Ramey <chet.ramey@case.edu>
> To: Mike Jonkmans <bashbug@jonkmans.nl>, bug-bash@gnu.org,
>  bash@packages.debian.org
> Cc: chet.ramey@case.edu
> Subject: Re: background, pipeline, hang
> Reply-To: chet.ramey@case.edu
> 
> On 7/12/19 10:00 AM, Mike Jonkmans wrote:
> 
> > Bash Version: 4.4
> > Patch Level: 20
> > Release Status: release
> > 
> > Description:
> > 	A pipeline, with two or more pipes, hangs when a background job is running.
> > 	Only when the background job finishes, the shell prompts again.
> > 	Without the background job, the shell prompts immediately.
> > 
> > Repeat-By:
> > 	: | : | : ## immediately finishes
> > 	sleep 10 &
> > 	: | : | : ## this hangs (^C, ^\, ^Z do not help) until the sleep finishes
> 
> Sorry, I can't reproduce this.
> 
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Thanks for looking, though.

With the tip of Greg Wooledge (use --norc --noprofile),
from another post, i was able to research this further.


This runs for two seconds:
	bash --norc --noprofile -ic "trap 'tput hs' DEBUG; sleep 2 & :|:|:"

While this immediately finishes:
	bash --norc --noprofile -ic "trap ':' DEBUG; sleep 2 & :|:|:"


I also found something in the (ubuntu)changelog, that might be related.
Quotes from "apt-get changelog bash":
	bash (4.3-6) unstable; urgency=medium
	[...]
	* Apply upstream patches 001 - 008:
	[...]
	- A change to save state while running the DEBUG trap caused pipelines to
      hang on systems which need process group synchronization while building
      pipelines.


It seems to have to do with the duration of the command executed in the DEBUG trap.
As this also exhibits an unexpected, longer duration:
	bash --norc --noprofile -ic "trap 'sleep 1; echo $SECONDS' DEBUG; sleep 5 & :|:|:"; echo $SECONDS

Compared to:
	bash --norc --noprofile -ic "trap 'echo $SECONDS' DEBUG; sleep 5 & :|:|:"; echo $SECONDS


So this combination is problematic:
- trap on DEBUG where the command takes some time
- something running in the background
- a pipeline with two or more pipes


Hope you can make something of this.

Regards, Mike

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: background, pipeline, hang Mike Jonkmans <bashbug@jonkmans.nl> - 2019-07-13 11:55 +0200

csiph-web