[PATCH] ash: clear NONBLOCK flag from stdin when in foreground

Denys Vlasenko vda.linux at googlemail.com
Wed Aug 17 13:13:09 UTC 2011


On Wed, Aug 17, 2011 at 3:00 PM, Alexey Fomenko
<ext-alexey.fomenko at nokia.com> wrote:
> Simple command line programs like cat or vi cat just stop working with
> an error: "Resource temprorarily unavailable". Busybox does not clear the
> NONBLOCK flag from stdin when it is in the foreground.

Which shell does that?

> fcntl(2) says:
>   File status flags
>       Each open file description has certain associated status flags,
>       initialized by open(2) and possibly modified by fcntl().  Duplicated
>       file  descriptors (made  with  dup(2),  fcntl(F_DUPFD), fork(2), etc.)
>       refer to the same open file description, and thus share the same file
>       status flags.
>
> This means that the programs you start from the command line, inheriting the
> shell's stdin/out/err can influence them, and by extension, influence all
> further programs to be launched.

Yes, this is a bug in Unix API. Nonblocking I/O should have been done
more sanely. Socket I/O has MSG_DONTWAIT flag which is *per-syscall*,
but ordinary read/write don't, and have to mess with file flags,

Please, ping LKML and ask them whether Linux is going to fix this mess.
(The more people nag developers about it, the higher are chances they'll
do something). My proposal was to make recv/send work on ordinary file
fd's too, and allow MSG_DONTWAIT flag to be used in this case.

-- 
vda


More information about the busybox mailing list