|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
At the following URL
http://groups.google.com/group/comp....read/thread/db... There is the following code #!/usr/local/ruby-1.8.0/bin/ruby require 'ftools' require 'tempfile' def compete who, f 5.times do |i| f.flock File::LOCK_EX f.puts format("%s:%d @ %f\n",who, i, Time.now.to_f) f.flock File::LOCK_UN end end path = format(__FILE__ + '.out') fd = open(path, File::WRONLY | File::TRUNC | File::CREAT) if fork compete 'PARENT', fd Process.wait rescue nil open(path){|f| puts f.read} fd.close File.rm_f path if File.exist? path else compete 'CHILD', fd end The code runs on my system. But, I don't see any call to Tempfile.new. I'm assuming it's implied? If it is being implied, where is it being implied at in the code? -- Posted via http://www.ruby-forum.com/. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
fd = open(path, File::WRONLY | File::TRUNC | File::CREAT)
|
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
> The code runs on my system. But, I don't see any call to Tempfile.new.
> I'm assuming it's implied? If it is being implied, where is it being > implied at in the code? tempfile isnt used as far as my knowledge goes...to test my theory? delete require 'tempfile' ... if the program still runs fine then ur gold. -- Posted via http://www.ruby-forum.com/. |
|
![]() |
| Outils de la discussion | |
|
|