http://qs321.pair.com?node_id=11131676


in reply to Re: File lock demo
in thread File lock demo

Hi Dave

I finally found the 45 min to watch the video. :)

I've actually been at this conference, pity I missed your talk.

I just wanted to add for the records that unfortunately your advise that

"you can unlink an open filehandle"

is not universally true. :/

This fails on Win:

> perl print my $file="random".rand(1000); open my $fh,">",$file or die $!; unlink ($file) or die $! __END__ Permission denied at - line 1. random741.284161646949

The same code runs without issues on linux

Thanks again! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: File lock demo
by davido (Cardinal) on Apr 24, 2021 at 17:27 UTC

    Thanks, that's good information. And how unfortunate, too. Every OS has its warts. I guess I'm happy with the devil I know (Linux).


    Dave

      > And how unfortunate, too.

      Thankfully I don't have the requirement for an "atomic deletion" of the file, because

      • I'm locking a semaphore file
      • the target files have unique names
      • their content is not security relevant
      • it's basically logging for observing state and retrieving errors

      But I'm trying to build my solution as OS agnostic as possible.

      I will let you know if I find something for "atomic deletion" on Win.°

      update

      °) though a use case might help to wrap my head around it. And Win has symlinks now...

      > I guess I'm happy with the devil I know (Linux).

      I still rather feel like a Linuxer even after 5 years in a Win project.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Re^3: File lock demo
by eyepopslikeamosquito (Archbishop) on Apr 24, 2021 at 22:06 UTC
      > This reminds me of a long battle I had with The Damian,

      For the records, no battle here. Davido only mentioned this after being asked, that was not part of any slides. :)

      > he made a boo boo

      FWIW I always thought that documentation should have a test suite too.

      At least the perldocs.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery