Reading stdin in Windows 7

Andrej Mitrovic andrej.mitrovich at test.com
Tue Aug 31 17:54:13 PDT 2010


Oooops, I meant:

std.stdio.StdioException: Bad file descriptor
type test.d | test.exe

works, but waits on exit:
test.exe | type test.d

works fine:
test.exe < test.d

Andrej Mitrovic Wrote:

> I get the same thing on XP.
> 
> If you swap the two like so:
> type.exe | type.d
> 
> Then it works but it will wait on exit.
> 
> This works nicely:
> 
> type.exe < type.d
> 
> Joel Christensen Wrote:
> 
> >  >>
> > 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