[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Terminal stop when a group of pipelines is piped to a pager

From: Abhijit Dasgupta
Subject: Terminal stop when a group of pipelines is piped to a pager
Date: Wed, 28 Sep 2016 07:35:33 +0000 (UTC)

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -D_FORTIFY_SOURCE=2 -g 
-O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat 
-Werror=format-security -Wall
uname output: Linux rho 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 
09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 11
Release Status: release


  The following stopping issue is seen in recent bash versions:

    $ { cmd_a; cmd_b | cmd_c; } | pager_prog

    [1]+  Stopped                  { cmd_a; cmd_b | cmd_c; } | pager_prog

  What is seen:  If a group of commands (in the above form) has its output
  piped to a pager program (e.g. more, less, etc), then they get stopped
  (by a SIGTTIN/SIGTTOU signal, while pager_prog accesses the tty).  This
  happens if the first command of the group (cmd_a) is not a bash builtin
  AND a pipeline occurs later in the group (cmd_b | cmd_c).

  Puzzlingly, the issue does not arise if in the command group either the
  first command (cmd_a) is a bash builtin or if none of the later commands
  contains a pipe.


  Specific examples to reproduce/illustrate the issue:

    { /bin/echo "Users"; who | sort; } | more                # Gets stopped
    { builtin echo "Users"; who | sort; } | more          # Works fine

    { date; who | sort; } | more                     # Gets stopped
    { who | sort; date; } | more                     # Works fine


  The problem goes away if we enclose the individual pipelines
  within the group (or the entire group) with a sh -c '...'.

Additional notes:

- The problem is still seen if the commands are grouped using parentheses
  (subshell) instead of braces, and also when pipelined commands are
  repeated in a loop, e.g.:

    for n in 1 2 ; do cmd_a | cmd_b ; done | pager_prog

    [1]+  Stopped                  for n in 1 2;
        cmd_a | cmd_b;
    done | pager_prog

- The problem is seen in all terminal types (xterm, linux console VT, etc)

- The problem is seen in bash versions 4.3.46 and 4.3.11, but not in 4.1.5.


Abhijit Dasgupta

reply via email to

[Prev in Thread] Current Thread [Next in Thread]