<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 1/4/2019 9:15 AM, Salz, Rich via
openssl-users wrote:<br>
</div>
<blockquote type="cite"
cite="mid:592EDC27-3851-407C-B04E-3BBA5B2E86D9@akamai.com">
<pre class="moz-quote-pre" wrap=""> Jakob - you’re a star! Thanks so much, your suggestion works. So I added
</dev/null to now give:
...
I’m wondering if this would be something worthy of attention in openssl?
Maybe open an issue to catch this. Seems like the apps could check and redirect to /dev/null if the FD isn't valid.
</pre>
</blockquote>
<p><br>
</p>
<p>All kinds of Bad Stuff will happen if file descriptors {0,1,2}
aren't set up right. Start with, say, an application opening a
database, getting fd 2 because that happens to be the first
available, and then for some reason writing an error message to
stderr.</p>
<p>I'd be shocked if cron starts an application without *something*
reasonable on {0,1,2}. I'd consider it to be a very serious bug
in cron. (I can't speak to anything else, but Solaris cron has 0
on /dev/null and 1 and 2 leading to a temporary file that gets
mailed to the user if non-empty.)<br>
</p>
<p>Whether an application should try to cope with such a broken
environment... shrug. Few if any do.</p>
<p>If you want to, what you want is something like:</p>
<pre> int fd;
do {
fd = open("/dev/null", O_RDWR);
} while (fd < 3);
close(fd);
</pre>
<p>(That's strictly not quite right, since it leaves 0 open writable
and 1 and 2 open readable, but that's pretty harmless.)<br>
</p>
<pre class="moz-signature" cols="72">--
Jordan Brown, Oracle Solaris</pre>
</body>
</html>