Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: rmtree() is failing after some time

by KristinaBurden (Initiate)
on Apr 23, 2009 at 13:51 UTC ( #759530=note: print w/replies, xml ) Need Help??


in reply to Re^3: rmtree() is failing after some time
in thread rmtree() is failing after some time

Thu Apr 23 18:02:04 2009 - WARN: cannot fetch initial working directory: No such file or directory at Basecamp/Setup.pm line 265 thread 8
This is the exact error message that I get.

Actually my code is scattered in many files, so I am not able to post more code.
I am calling rmtree() in DESTROY() method of a class.
  • Comment on Re^4: rmtree() is failing after some time

Replies are listed 'Best First'.
Re^5: rmtree() is failing after some time
by grinder (Bishop) on Apr 23, 2009 at 20:30 UTC
    I am calling rmtree() in DESTROY() method of a class

    The error is due to the fact that the code is unable to stat the directory in question. Is the path canonical or relative? If it's relative, is your code's working directory where you think it is? Can you prove it (print getcwd)?

    How are you generating your temp names? Could two threads create the same name?

    In general, putting resource teardown code beyond closing a socket or the like in a DESTROY handler is a bit weird. I think you'll need to solve this with another a level of indirection. You have to go up a level and ask some parent code to clean up afterwards.

    • another intruder with the mooring in the heart of the Perl

      In general, putting resource teardown code beyond closing a socket or the like in a DESTROY handler is a bit weird.

      I have to disagree. If I have resource creation in new or other constructor, I often put cleanup of that resource in DESTROY. If the resource is managed by the object, shouldn't the object do the cleanup?

      I guess my C++ background shows here. I see putting the cleanup code in DESTROY as serving to hide those implementation details from the caller of my object. It also tends to reduce the need for cleanup code to be repeated everywhere the object is used (DRY principle).

      G. Wade

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://759530]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2021-11-27 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?