From: Daniel Berger Date: 2008-05-29T03:34:38+09:00 Subject: Re: Ensuring only one instance of a script is running On May 20, 11:18 pm, Heesob Park wrote: > DanielBergerwrote: > > Hi all, > > > I'm probably late to the game on this, but I stumbled across an > > interesting use for DATA. You can use it to ensure only one instance > > of a given script is running by using flock: > > > class Foo > >    def self.mainloop > >       while true > >          puts "Looping..." > >          sleep 3 > >       end > >    end > > end > > > DATA.flock(File::LOCK_EX) > > I think the above is actually equal to > > File.new($0).flock(File::LOCK_EX) It would seem so. Sean O'Halpin has expanded on it a bit, too. Regards, Dan