Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Rename unreliable on Windows

by Corion (Pope)
on Apr 04, 2012 at 09:49 UTC ( #963393=note: print w/replies, xml ) Need Help??

in reply to Rename unreliable on Windows

So why are you sure that "permission denied" is not actually the cause? Maybe you don't know that file locking is obligatory on Windows? If another application has opened a file in exclusive mode, renaming it will give you "permission denied" on Windows for example.

Replies are listed 'Best First'.
Re^2: Rename unreliable on Windows
by elef (Friar) on Apr 04, 2012 at 10:01 UTC
    I didn't say that "permission denied" is not actually the cause... It could be, technically, in some roundabout way.
    The more relevant question is, what other application could have possibly opened the file in exclusive mode and why? I can't see an answer to that in the test script above, which fails for me with "Permission denied" somewhere between loop 1 and loop 900 every time.

      Maybe your virus scanner, maybe your backup application, maybe some other program. How would we know? think that the Sysinternals Tools have some program to show what programs hold a filehandle to a file, but I don't know.

      If in doubt, I would talk to the system administrator for the machines in question.

        think that the Sysinternals Tools have some program to show what programs hold a filehandle to a file,

        Yes. it is called handle.exe:

        C:\test>handle /? Handle v3.42 Copyright (C) 1997-2008 Mark Russinovich Sysinternals - usage: handle [[-a [-l]] [-u] | [-c <handle> [-y]] | [-s]] [-p <proces +s>|<pid>] [name] -a Dump all handle information. -l Just show pagefile-backed section handles. -c Closes the specified handle (interpreted as a hexadecimal nu +mber). You must specify the process by its PID. WARNING: Closing handles can cause application or system ins +tability. -y Don't prompt for close handle confirmation. -s Print count of each type of handle open. -u Show the owning user name when searching for handles. -p Dump handles belonging to process (partial name accepted). name Search for handles to objects with <name> (fragment accepted +). No arguments will dump all file references.

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

        Thanks for that one!
        It was indeed my backup sw (WD anywhere backup). After disabling it, the test script runs to 10000 loops without errors.

        Followup question: why does this happen and is there an easy workaround (apart from disabling the backup sw)? I mean, I don't think I've had problems with deleting or modifying files, only renaming... And I don't think I've had issues outside of perl.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://963393]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2018-03-21 06:20 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (264 votes). Check out past polls.