help-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: recursive commands


From: Craig Allan Jeffree
Subject: Re: recursive commands
Date: Tue, 02 Apr 2002 23:14:09 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020205

Niels Möller wrote:

If I understood the issue correctly, rm -r will do
things like

 chdir("foo");
 delete stuff
 chdir("..");
 delete more stuff

That's bad if directories are moved around between the two chdir
calls. The right way to recurse is something like

 old = open(".");
 chdir("foo);
 delete stuff
 fchdir(old);
 delete more stuff

Isn't this potentially racey as well? I can see that fchdir(old); will definately take you back to the parent of "foo" but how can you be sure that the directories aren't moved around between step 1 and 2? You could end up in a different "foo" to what you intended, I guess this is a different issue - but it is still an issue isn't it?

Regards,
Craig.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]