On Wednesday 11 November 2009 23:18, Johannes Stezenbach wrote: > On Wed, Nov 11, 2009 at 08:00:30PM +0100, Denys Vlasenko wrote: > > > > Applications which need to do nonblocking reads need to: > > (1) try to obtain a non-shared fd; or > > (2) clean up after themself; or > > (3) switch O_NONBLOCK on/off momentarily before/after read; or > > (4) use some other way (poll()? read() interrupted by ALRM?); > > * and in any case * > > (5) bug standard committees and/or Linux kernel people > > to fix the damn mess > > IMHO the shell cannot rely on apps doing the cleaning up, > it should be able to deal with buggy apps, or apps killed > by some signal etc. > > In the interest of compatibility, wouldn't it be best to > find out what other shells do and do the same?
bash clears O_NONBLOCK if it reads commands from stdin. That's the only case when it does so. Which tells me that bash is doing it just because otherwise it gets EWOULDBLOCK error on read(), not in the name of cleaning up after crashed apps. Had it been the case, it's do the same when it runs a script. > Also, a general purpose toolkit like busybox should also > work on old kernels (and perhaps even non-Linux kernels)? > Thus a hypothetical kernel fix would buy you nothing. Hypothetical kernel fix would make it possible to forget about this problem in ~10 years, when almost everyone would use sane(r) nonblocking I/O API. -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
