<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
David T. Lewis escreveu:<br>
<blockquote cite="mid:20090515211045.GA4224@shell.msen.com" type="cite">
  <pre wrap="">
Do you mean that the external library is writing to stdout, and you
want to be able to see that output from within the Squeak image? In
that case you want Squeak to be reading its own standard output, and
redirecting it to the Transcript?

(...)</pre>
</blockquote>
Yes, I have something like (the most time consuming routine):<br>
<br>
<font face="Courier New, Courier, monospace">&nbsp;&nbsp;&nbsp; fInterface
apiFannTrain: theFANN<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; onFile: trainingDataFileName<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; times: theMaxEpochs<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; reporting: numberOfEpochs<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; toPrecision: theDesiredError.&nbsp;&nbsp;&nbsp; </font><br>
<br>
Where apiFannTrain is:<br>
<br>
<font face="Courier New, Courier, monospace">apiFannTrain: aFann
onData: aTrainData times: aNumber1 reporting: aNumber2 toPrecision:
aFloat<br>
&nbsp;&nbsp;&nbsp; &lt; cdecl: void 'fann_train_on_data' ( Fann* FannTrainData* ulong
ulong float ) module: 'floatfann' &gt;<br>
&nbsp;&nbsp;&nbsp; ^ self externalCallFailed.</font><br>
<br>
And that routine outputs progress to stdout. Problems are:<br>
<br>
<ol>
  <li>As I cannot redirect stdout from inside squeak, I'm not able to
watch progress inside squeak (Transcript, morph... you name it)</li>
  <li>As this kind of output doesn't create context change within
squeak VM, apiFannTrain freezes VM until its completion (which may take
more than 12 hours). Geez, it's a long time with frozen squeak...</li>
</ol>
I just figured out that if it was possible to redirect stdout to
something inside squeak it would allow me to fix the two problems.<br>
<br>
<blockquote cite="mid:20090515211045.GA4224@shell.msen.com" type="cite">
  <pre wrap="">Or direct stdout to a named pipe (unix mkfifo command) and read from
the named pipe. If you use a named pipe, you will need to open it as
a file stream in Squeak, then set the file stream to non-blocking mode
before you use it, otherwise you will lock up your Squeak VM. Search
for methods with 'setnonblocking' in the name. It's somewhere in
OSProcess, but I don't have Squeak with me to check right now.

Dave



  </pre>
</blockquote>
<br>
</body>
</html>