in reply to remove_tree dies even when trapped with eval

system( "rm -rf /path/to/tree" );

[...] But I obviously want to avoid the system call with it's fork.

Good plan. But if, for some strange reason, it is unavoidable, please use the list form of system, i.e. system("/bin/rm","-rf","/path/to/tree") to avoid nasty surprises from the shell.

I'd like to delete a complete path which sits on an NFS export, and the network is slightly unreliable. [...] rm also complains from time to time that the directory is not empty, but at least the script stays alive, and I can retry. It then always succeeds on the second attempt. I never need a third one.

NFS caches some information about non-local files for a while (three seconds by default), without consulting the server. This may confuse the local system. See nfs(5).

Depending on how the NFS export is mounted, access to it may block (hard mount) or fail (soft mount). Again, see nfs(5).

Another funny thing that may happen is that another computer creates files in the directory tree that you are deleting. (Race Condition)

And finally, consider making the network work more reliably.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)