Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: pipeline that cannot be interrupted



On 2022-04-26 11:18:33 +0200, Vincent Lefevre wrote:
> Date: Fri, 2 Aug 2019 16:51:06 +0200
> From: Vincent Lefevre <vincent@xxxxxxxxxx>
> To: zsh-workers@xxxxxxx
> Subject: [BUG] pipeline that cannot be interrupted with Ctrl-C (regression)
> 
> With zsh 5.7.1 under Debian, the following pipeline cannot be
> interrupted with Ctrl-C:
> 
>   { /bin/sleep 10 ; /bin/sleep 20; } | { /bin/sleep 30 ; /bin/sleep 40; }
> 
> But if I remove one of the sleep, it can be interrupted by Ctrl-C.
> 
> There was no issue with zsh 5.3.1 (Debian 9).
> 
> Note: I mentioned this example in zsh-users in the thread
> "kill the LHS command of a pipe once the RHS command terminates".

More tests similar this one:

zira% {
  echo L1 > /dev/tty
  /bin/sleep 10
  echo L2 > /dev/tty
  /bin/sleep 20
  echo L3 > /dev/tty
} | {
  echo R1 > /dev/tty
  /bin/sleep 30
  echo R2 > /dev/tty
  /bin/sleep 40
  echo R3 > /dev/tty
}
R1
L1
^CR2
^C^C^C^C^\^\

So the "/bin/sleep 30" gets interrupted by Ctrl-C, then
Ctrl-C and Ctrl-\ are ignored until "/bin/sleep 40" ends.

With "date" (a command) instead of the "echo" builtin, the signals
are ignored until the "/bin/sleep 20" ends, and before the 3rd date
command:

zira% {
  date "+L1 %F %T" > /dev/tty
  /bin/sleep 10
  date "+L2 %F %T" > /dev/tty
  /bin/sleep 20
  date "+L3 %F %T" > /dev/tty
} | {
  date "+R1 %F %T" > /dev/tty
  /bin/sleep 30
  date "+R2 %F %T" > /dev/tty
  /bin/sleep 40
  date "+R3 %F %T" > /dev/tty
}
R1 2022-04-26 12:00:50
L1 2022-04-26 12:00:50
^C^C^C^\^\L2 2022-04-26 12:01:00
^C^C^C^\^\
zira% 

with the prompt at 2022-04-26 12:01:20.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Messages sorted by: Reverse Date, Date, Thread, Author