find -execdir executes in wrong dir

Corinna Vinschen
Mon Nov 22 11:19:00 GMT 2010

On Nov 21 05:02, pdanford wrote:
> I just upgraded to version 1.7.7-1 and the following find command is
> broken (which used to work correctly in a recent 1.7x version):
> C:\cygwin\bin\find . -name file.txt -type f -execdir pwd ';'
> Apparently, if there are say 10 matching file.txt files, -execdir
> executes the command in the first dir over and over. However, the
> following use of find works correctly:
> C:\cygwin\bin\find . -name file.txt -type f -execdir pwd '{}' +

It appears that this is a problem in find 3.5.9.

I can reproduce this problem, even under Cygwin 1.7.5, and I examined
the strace output.  What happens is that find forks for each call to
pwd.  The forked find then calls fchdir before calling exec("pwd").

And here's the problem.  Each single fchdir is called with the exact
same directory descriptor.  There is an open file descriptor (fd 7)
which holds a handle to the *correct* directory, but the forked find
calls fchdir(4), which is a file descriptor holding the first directory
containing the file.

This does not occur when using find 3.5.8.

Eric?  Would you mind to have a look?


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list