dub build output redirect

seany seany at uni-bonn.de
Tue Jun 8 14:05:36 UTC 2021


On Tuesday, 8 June 2021 at 13:51:10 UTC, Steven Schveighoffer 
wrote:
> On 6/8/21 8:38 AM, seany wrote:
>> I have compiled a complex project via `dub build`.
>> 
>> I used both `-b release` and `-b debug`.
>> 
>> But i cant redirect the output (generated by `writeln`) to a 
>> file.
>> 
>> I call by : `./executable --param p1 > a`. But execution hangs 
>> immediately. If I do `./executable --param p1 ` no issue.
>> 
>> What am I doing wrong?
>> 
>> thank you.
>
> Are you expecting input as well as sending output?
>
> A common behavior difference between console streams and file 
> streams (including in D) is that when the library detects it's 
> sending to a console, it flushes buffered output after every 
> newline. When it's sending to a file (or other stream type), it 
> only sends output when the buffer is full (usually about 4k 
> bytes).
>
> The hang sounds like it has buffered up its output ready to 
> send, and then is waiting for input to continue.
>
> -Steve

Hi

Thank you for pointing this out.

Indeed, much later in the code, there is a `readln()`.
But, the program needs to run 1-2 minutes, until it reaches that 
point - it is doing a complex AI calculation.

However, for these 1-2 minutes, there is no output. Not via 
`tee`command, also not when i do a `tail -f a` (`a` is the 
logfile as in my last mail). I expect  the output of these 1-2 
minutes, until the `readln` point to be visible via either of 
these to methods.

Is it still the same case as you describe?


More information about the Digitalmars-d-learn mailing list