|Subject:||remove_tree() is not thread-safe due to chdir|
I have a multi-threaded program which calls make_path() and remove_tree(). I observed some occasional failure from subprocesses about missing working directory. Now I got a croak from remove_tree() that removing directory is not empty. It happened that one thread started remove_tree() which made chdir(), then the other thread called and finished make_path(), and finally, the former thread continued in remove_tree() which failed because concurrent make_path() created relative directory tree into working directory changed by remove_tree(). All this is tread-unsafety is due to using chdir(). Working directory is a process attribute shared between threads. It would be nice to reimplement File::Path without changing working directory. Or at least document this deficiency.