Hi,

Am Dienstag, 08. Sep 2009, 01:11:23 +0900 schrieb Eleanor McHugh:
> On 7 Sep 2009, at 12:56, Bertram Scharpf wrote:
>>
>>  t = Thread.new {
>>    puts `echo foo; sleep 1; echo bar`
>>  }
>>  puts `echo baz; sleep 1; echo quux`
>>  t.join
>>
>> Stricly spoken it's not blocking. The "baz" is written to its pipe
>> before "bar". But it is stored until "quux" is echoed and puts is
>> asked to write it out.
>
> From Ruby's perspective the backtick is definitely a blocking IO operation, 
> just as it is in shell script.

Yes, of course. I just examined the interpreter's source. The
waitpid function is called _without_ the WNOHANG flag. Before that
the child processes output is read and appended to a string until
the stream is closed what usually happens when the program
terminates.

What I meant was just that the child process is really running and
writing "foo" and "baz" to the pipes 1 second before the output
can by noticed in the parent.

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de