Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Where is the call to Tempfile.new in this code?
Chad
9/15/2007 9:50:00 PM
At the following URL
http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/db1d1d63b26d371/21bba01335a8615c?lnk=gst&q=mandatory+locks&rnum=3#21bba0...
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?
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Where is the call to Tempfile.new in this code?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password