<div dir="ltr">On Mon, Sep 15, 2008 at 7:22 PM, Matthew Fluet <span dir="ltr">&lt;<a href="mailto:fluet@tti-c.org">fluet@tti-c.org</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Mon, 15 Sep 2008, Wesley W. Terpstra wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">The problem is that -mwindows removes the stdin/out/err file descriptors<br>
from the program.<br>
</blockquote>
<br></div>
What happens to an &#39;fprintf(stderr,...);&#39; or an &#39;fwrite(s,size,n,stderr);&#39; statement with -mwindows? An exception raised during the evaluation of the Basis Library will be printed using functions from &lt;src&gt;/runtime/basis/Stdio.c. &nbsp;(See &lt;src&gt;/basis-library/primitive/prim2.sml.)</blockquote>
<div><br>They will all silently fail. The C code in my previous email will correct std*, however, so if it is called soon enough, stderr will work.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">There are two fixes that come to mind:<br>
1) handle/ignore the exception from fstat (isReg posix/io.sml:187)<br>
2) setup place-holder stdin/out/err if none exist<br>
<br>
I tend towards option #2.<br>
</blockquote>
<br></div>
How does one determine that stdin/out/err &#39;exist&#39;? &nbsp;It seems as though they exist as values/handles, but don&#39;t support the full range of operations.</blockquote><div><br>The test fileno(stdout) == 1 in my previous email has worked on all the platforms / combinations I was able to test.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
However,<br>
if stderr is missing one loses exception information. Perhaps it could<br>
create a popup window. A TextPrimIO.writer that creates a window and adds<br>
text on write* calls shouldn&#39;t be that hard to implement.<br>
</blockquote>
<br></div>
As noted above, this wouldn&#39;t help in this situation, because the exception printer (that is in scope for the evaluating the Basis Library) doesn&#39;t go through TextIO.print.<br>
</blockquote></div><br>Yes. I no longer advocate this. My current suggestion is that we instead attach a hidden console, and display it if it is used.<br><br></div>