From: Ronan Pigott <rpigott314@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: zsh mysteriously suspending job with sudo
Date: Sat, 22 Feb 2020 18:09:13 -0700 [thread overview]
Message-ID: <CAG4d5Bg=vkj6PYYGVyNO3pWTh=RkT=2rTFdE_hPBj1xxz6YTSw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2405 bytes --]
Hello zsh users,
I've encountered an unusual bug using zsh and I finally have a reliable
reproduction so I'm looking for some insight. The issue is as follows:
===
$ sudo true
[sudo] password for ronan:
$ pacman -Qttdq | sudo pacman -Rns -
[...]
:: Do you want to remove these packages? [Y/n] zsh: done
pacman -Qttdq |
zsh: suspended (tty output) sudo pacman -Rns -
===
When I try to pipe a package list for pacman to read from stdin, the job is
mysteriously suspended by zsh when "pacman -Rns -" prompts [Y/n] for
confirmation to continue, before I have a chance to input anything. I have
not
input the SUSP character. The issue is also reproducible from a 'zsh -f' in
a
clean environment.
Trying to 'fg' the suspended job always results in the following error:
===
$ fg[1] + done pacman -Qttdq |
continued sudo pacman -Rns -
zsh: can't set tty pgrp: no such process
===
I can only reproduce in zsh, not bash. The issue also only occurs when sudo
*does not* prompt for a password, which is why I use a "sudo true" to
temporarily authorize my user before demonstrating the issue.
Bizarrely, the following examples all work as intended:
===
# with an extra file
$ pacman -Qttdq > packages.txt; cat packages.txt | sudo pacman -Rns -
[...]
:: Do you want to remove these packages? [Y/n]
# with an extra cat
$ pacman -Qttdq | cat - | sudo pacman -Rns -
[...]
:: Do you want to remove these packages? [Y/n]
# with process substitution
$ sudo pacman -Rns - < <(pacman -Qttdq)
[...]
:: Do you want to remove these packages? [Y/n]
===
To exonerate pacman, a user from #archlinux helped create a script that
exhibits
similar behavior:
===
$ cat read-and-prompt.sh#!/bin/sh --
exec 3<&1
while IFS= read -r input; do
printf '%s\n' "$input" >&3
done
exec < /dev/tty
printf 'prompt: ' >&2
read -r _
exec "$@" <&3
$ for a in a b c; do print "$a"; sleep 1; done | sudo ./read-and-prompt.sh
cat
a
b
c
prompt:zsh: done for a in a b c; do; print "$a"; sleep 1;
done |
zsh: suspended (tty input) sudo ./read-and-prompt.sh cat
===
They also report that they cannot reproduce using doas in place of sudo.
Considering the above, I believe my issue is a bug in either sudo or zsh,
hence
why I am asking here.
Why is zsh suspending this job? My understanding is that jobs are suspended
only
in response to a signal, but I do not know where it could be generated in
this
case.
next reply other threads:[~2020-02-23 1:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-23 1:09 Ronan Pigott [this message]
[not found] <CAG4d5Bg=vkj6PYYGVyNO3pWTh=RkT=2rTFdE_hPBj1xxz6YTSw__29611.299622205$1582420251$gmane$org@mail.gmail.com>
2020-02-23 14:03 ` Stephane Chazelas
2020-02-23 18:53 ` Ronan Pigott
2020-02-23 23:57 ` Ronan Pigott
2020-05-14 21:15 ` Ronan Pigott
2020-05-15 9:08 ` Peter Stephenson
2020-05-15 9:20 ` Ronan Pigott
2020-02-23 20:18 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAG4d5Bg=vkj6PYYGVyNO3pWTh=RkT=2rTFdE_hPBj1xxz6YTSw@mail.gmail.com' \
--to=rpigott314@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).