From: "Berger, Daniel" <Daniel.Berger / qwest.com>
> 
> > > io =IO.popen('date /t')
> > > io.close
> > 
> > Why curious?
> > 
> > That date command tries to write to the pipe, but it has been 
> > closed before it.  That is the message from cmd.exe.
> 
> But I haven't closed it until after the command has finished, have I?

popen forks the process.  The command runs asynchronously in a separate
process.  If the parent immediately closes the pipe, who knows how far
along the child had gotten in completing its task?  (Probably not far.)

> Also, Linux does not emit any warning using the same code (replacing
> 'date /t' with just 'date').
>  
> > > However, this code does not:
> > > 
> > > io = IO.popen('date /t')
> > > io.gets
> > > io.close
> > 
> > Because the output is just one line, and it is read by gets.
> 
> If io.gets works, then the date output has already been written to the
> IO object in the IO.popen call, right? So, why would it complain about
> the pipe being closed?

gets blocks until it receives output, which in this case is sufficient
for the child to have completed its task (since the child only writes
one line of output.)


Regards,

Bill