[PATCH] Ensure standard file descriptors are open on start

Arsen Arsenović arsen@aarsen.me
Tue Aug 18 22:31:39 GMT 2020


> > -  check_one_fd (STDIN_FILENO, O_WRONLY | O_NOFOLLOW);
> > -  check_one_fd (STDOUT_FILENO, O_RDONLY | O_NOFOLLOW);
> > -  check_one_fd (STDERR_FILENO, O_RDONLY | O_NOFOLLOW);
> > +  check_one_fd (STDIN_FILENO, O_RDONLY | O_NOFOLLOW);
> > +  check_one_fd (STDOUT_FILENO, O_WRONLY | O_NOFOLLOW);
> > +  check_one_fd (STDERR_FILENO, O_WRONLY | O_NOFOLLOW);
> 
> Why is this change needed? Even if ISO C requires that standard streams be
> open, it doesn't require that one can do I/O successfully with the streams.
It seems to me that the sanest option would be making all three file descriptors
read/wrote only (as appropriate), by opening /dev/null. This makes all reads
EOFs and all writes successful, which would be what, at least, I expect when
closing one of the standard streams.
Regardless, with and without this change, the configure script I mentioned still
runs fine (since the standard streams it rightfully assumes exist indeed do
exist), so I can remove it, if that's a better solution.
-- 
Arsen Arsenović
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20200819/8913c608/attachment.sig>


More information about the Libc-alpha mailing list