Plea to use STD{IN, OUT, ERR}_FILENO instead of constants [was: Re: svn commit: trunk/busybox/shell]

Denys Vlasenko vda.linux at googlemail.com
Thu Nov 1 18:54:47 UTC 2007


On Monday 29 October 2007 21:10, Bernhard Fischer wrote:
> > #if ENABLE_ASH_READ_TIMEOUT
> > 	if (ts.tv_sec || ts.tv_usec) {
> >-// TODO: replace with poll, it is smaller
> > 		FD_ZERO(&set);
> > 		FD_SET(0, &set);
> 
> It would be nice if (long-term) we could strive to use the respective
> STD{IN,OUT,ERR}_FILENO defines for these.
> > 
> >-		i = select(FD_SETSIZE, &set, NULL, NULL, &ts);
> >-		if (!i) {
> >+		/* poll-based wait produces bigger code, using select */
> >+		i = select(1, &set, NULL, NULL, &ts);
> 
> likewise.
> 
> PS: while for /me, it's perfectly clear what these usually boil down to,
> it is more elaborate to read and easier to understand for beginners if
> the defines are used. But more importantly, as Shaun Jackman and others
> did point out more than once:
> "
> More importantly, it
> allows a header to redefine STDIN_FILENO to fileno(stdin) so that
> stdin may be replaced by a socket on a system that does not support
> dup2.
> "
> So, IMHO, it's a matter of cleanlyness to use STD{IN,OUT,ERR}_FILENO
> where possible.

Ok, will gradually do that.
--
vda



More information about the busybox mailing list