help-bash
[Top][All Lists]
Advanced

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

Re: bash read error


From: Greg Wooledge
Subject: Re: bash read error
Date: Wed, 1 Jun 2022 10:24:50 -0400

On Wed, Jun 01, 2022 at 04:11:37PM +0200, Pascal wrote:
> thank you Greg for these explanations and for these last three lines are
> perfect for me.
> 
> reading fails in the background process ("simply") because the keyboard is
> monopolized (attached/reserved) by the foreground process ?

That's... not an entirely incorrect statement, I suppose.  Not the way I
think of it, though.

>From read(2) on Linux:

       EIO    I/O error.  This will happen for example when the process is  in
              a  background  process group, tries to read from its controlling
              terminal, and either it is ignoring or blocking SIGTTIN  or  its
              process  group  is  orphaned. [...]

Background jobs can't read from a terminal, because it would result in
complete chaos.  Imagine you're running a nice, normal interactive
foreground job, like a shell.  You try to type in the shell, which wants
to read your input, but there's a background job that's running, which
is also trying to read your input.  Who gets it?  Would half of your
keystrokes go to your foreground shell, and half get sucked up by the
background process?

Nobody wants that, so the rule is "background processes can't read from
the terminal".  There may be weird exceptions or something, I dunno, but
that's enough for me.



reply via email to

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