Reading stdin in Windows 7

Joel Christensen joelcnz at gmail.com
Tue Aug 31 17:15:30 PDT 2010


 >>
Stanislav Blinov <blinov loniir.ru> writes:
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

   Hello,

I'm receiving strange results with reading stdin on Windows 7. Consider
this code:

module test;

import std.stdio;

void main(string[] args)
{
          foreach (int i, string line; lines(stdin))
          {
                  write(line);
          }
}

On Linux, if I do 'cat test.d | ./test' I get test.d contents on stdout.
But on Windows 7, ('type test.d | ./test.exe') the output is this:

std.stdio.StdioException: Bad file descriptor
module test;

import std.stdio;

void main(string[] args)
{
          foreach (int i, string line; lines(stdin))
          {
                  writef(line);
          }
}

So I too get type.d contents on stdout, but preceeded by StdioException
string. This happens with dmd 2.047 and 2.048.

Is this my error, dmd's, or Windows's piping?
-- 
Aug 17

<<

 >Jesse Phillips <jessekphillips+D gmail.com>
 >In my experience Windows hasn't gotten piping right. And it has been 
 >known to
 >have bugs, this might be related:
 >http://stackoverflow.com/questions/466801/python-piping-on-windows-why-does-this-not-work
 > Aug 18

Joel Christensen <joelcnz gmail.com>:
Just dug up this problem. I have trouble with Thunderbird and so 
couldn't put reply.

I've tried that solution on my Windows 7, but got no effect at all.
Sept 1


More information about the Digitalmars-d-learn mailing list