Subject: bug#21972: 24.5; Running 'bash -i -c' via shell-command hangs on FreeBSD

From: Eli Zaretskii <[email-masked]>
Date: Mon, 14 Oct 2019 23:09:28 +0300

> From: Stefan Kangas <[email-masked]>
> Date: Mon, 14 Oct 2019 21:55:22 +0200
> Cc: [email-masked]
> 
> Davor Cubranic <[email-masked]> writes:
> 
> > On FreeBSD, running:
> >
> >   M-x shell-command
> >   /usr/local/bin/bash -i -c "echo hello"
> 
> On GNU/Linux, the above gives me:
> 
> bash: cannot set terminal process group (-1): Inappropriate ioctl for device
> bash: no job control in this shell
> hello
> 
> > hangs until you press C-g (twice). I can see the bash process running at
> > 100% via `top` until C-g kills it.
> >
> > Adding `--norc --noprofile` to the command still hangs, so it's not
> > anything about the shell initialization files. The `-i` option is the
> > key: without it, everything works fine.
> >
> > Running the same command via `async-shell-command` does not hang: Bash
> > outputs "hello" in the "*Async Shell Command*" buffer and exits.
> >
> > Both Emacs and Bash are standard FreeBSD 10 binary packages installed
> > via `pkg`. (emacs24-24.5_1,3 and bash-4.3.42, respectively).
> 
> If bash hangs, shouldn't that be reported as a bug in bash instead?

It's possible that your Bash is newer, and this bug was fixed since
then.

In general, it sounds like Bash tries to read from its stdin, and in
call-process that is... what?  By contrast, by default we communicate
with async subprocess via PTYs (on Posix hosts), which is what Bash
expects in an interactive session.

IOW, I cannot understand why would someone call "bash -i" in a
non-interactive command.

> Or should Emacs somehow do better with a hanging process?

Like what?