On May 20, 11:18 ¨Âí¬ Èååóïâ Ðáòë ¼ðèá®®®Àçíáéì®ãïí¾ ÷òïôåº
> 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
> >  ¨Âåæ óåìæ®íáéîìïï> > while true
> >  ¨Âõô¢Ìïïðéîç®®®¢
> >  ¨Âìååð > > 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