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

I am a newbie in Perl. What is strace or truss? Point here is that rmtree() is able to delete temp folders initially but after some time it starts giving this error. And I restart my perl program then also, initially it is able to delete them but after 20-25 folders it starts giving error. My perl program creates threads(8-10), each thread creates a temp folder, processes it and then deletes it. Initially all threads behave well. After some time, error starts appearing.
  • Comment on Re^2: rmtree() is failing after some time

Replies are listed 'Best First'.
Re^3: rmtree() is failing after some time
by dHarry (Abbot) on Apr 23, 2009 at 12:36 UTC

    See strace/truss. It's a runtime call monitor for Perl, to find out where the problem is.

    failed to fetch initial working directory

    Is this the exact error message you get? I have a feeling that it's an issue with threading (you didn't mention in your post you use threads). Maybe you should post more code so we can take a look at it.

      I am calling rmtree() in DESTROY() method of a class. Here is the exact error message Thu Apr 23 18:08:24 2009 - WARN: cannot fetch initial working directory: No such file or directory at Basecamp/Setup.pm line 265 thread 6 Code is scattered in different files so I am not able to post more code.

        Code is scattered in different files so I am not able to post more code

        Sure you can, or is it secret code;)

        Without code it's a bit hard/impossible to diagnose the problem correctly. My guess right now is that in some thread some piece of code tries to access a directory which has just been deleted by the rmtree in another thread?!

      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.
        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