Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15463
| From | Matteo Croce <mcroce@redhat.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: bash sets O_NONBLOCK on pts |
| Date | 2019-10-02 19:59 +0200 |
| Message-ID | <mailman.788.1570039210.2651.bug-bash@gnu.org> (permalink) |
| References | <CAGnkfhzCqfL03_Ox+awRvd2gmu+OQy4J8qbzQLiaO3sQgQcGqA@mail.gmail.com> <5d94e361.21745@msgid.achurch.org> <CAGnkfhwz-1DE+yKFGi-yCviQeAE_2h2-p7rhA1xOt7pPzXBdkg@mail.gmail.com> |
On Wed, Oct 2, 2019 at 7:50 PM Andrew Church <achurch@achurch.org> wrote:
>
> >Well, it's not so uncommon, I had it a few times. Reading on internet
> >it seems that other users have it but don't notice it.
>
> The fault could be in some other program accessing the terminal. Bash
> does not clear O_NONBLOCK on displaying a prompt, so if a previously
> executed program sets O_NONBLOCK on stdin and then exits, that state
> will remain until some other program unsets it. For example:
>
> $ cat >foo.c
> #include <fcntl.h>
> int main(void) {fcntl(0, F_SETFL, O_NONBLOCK); return 0;}
> ^D
> $ cc foo.c
> $ ./a.out
> $ cat
> cat: -: Resource temporarily unavailable
>
> --Andrew Church
> http://achurch.org/
It seems to me that bash restores the flag, cat prints an error when not:
$ cat
$
the same is not true if running multiple commands:
$ ./foo; cat
cat: -: Resource temporarily unavailable
$
Why this different behaviour?
Regards,
--
Matteo Croce
per aspera ad upstream
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: bash sets O_NONBLOCK on pts Matteo Croce <mcroce@redhat.com> - 2019-10-02 19:59 +0200
csiph-web