Strange problem with find and directories

Lavrentiev, Anton (NIH/NLM/NCBI) [C] lavr@ncbi.nlm.nih.gov
Thu May 16 01:56:00 GMT 2013


> I meant /cygdrive/c/...

... and I was trying to identify the problem myself but got into another thing,
now with strace:

when trying to use the "-f" flag that I used to use on Linux to trace
child processes, the entire command just hanged:

$ strace -f -o find.strace find . -name dir -type d -exec rm {} \;

it turned out that strace was waiting on a child to exit:

   35   35094 [main] find 7872 time: 1368668019 = time(0)
11696   46790 [main] find 7872 frok::parent: forked pid 7568
   61   46851 [main] find 7872 child_info::sync: n 2, waiting for subproc_ready(0x25C) and child process(0x280)

I figured I was doing something wrong, so I tried to see the version of strace:

$ man strace
...
       -v, --version
              output version information and exit
...

That did not work, either:

$ strace -v
C:\Cygwin\bin\strace.exe: unknown option -- v
Try `strace --help' for more information.

$ strace --help
...
  -V, --version                output version information and exit
...

So man page needs to be more *case-sensitive*.  Also, it looks like -f
actually turns off the child tracing (and that obviously does not work
with the never-ending wait).  What's more, the interrupted (Ctrl-C) strace
left the find process still running (it showed up in Task Manager, but
not with Cygwin's "ps" run from bash/minny window) -- I discovered that
by the fact that when I tried to remove the file "strace.find", I got this:

rm: cannot remove `find.strace': Device or resource busy

Finally, I had strace running without the -f switch, and it finished
successfully, showing the following sequence in the trace file leading
to errno 20 (ENOTDIR):

   27   86111 [main] find 5420 mount_info::conv_to_win32_path: src_path /home/lavr/test/dir, dst C:\Cygwin\home\lavr\test\dir, flags 0x3000
A, rc 0
   58   86169 [main] find 5420 symlink_info::check: 0xC0000034 = NtCreateFile (\??\C:\Cygwin\home\lavr\test\dir)
   29   86198 [main] find 5420 symlink_info::check: 0xC0000034 = NtQueryInformationFile (\??\C:\Cygwin\home\lavr\test\dir)
   49   86247 [main] find 5420 symlink_info::check: 0xC0000034 = NtCreateFile (\??\C:\Cygwin\home\lavr\test\dir.exe)
   32   86279 [main] find 5420 symlink_info::check: 0xC0000034 = NtQueryInformationFile (\??\C:\Cygwin\home\lavr\test\dir.exe)
   45   86324 [main] find 5420 symlink_info::check: 0xC0000034 = NtCreateFile (\??\C:\Cygwin\home\lavr\test\dir.lnk)
   27   86351 [main] find 5420 symlink_info::check: 0xC0000034 = NtQueryInformationFile (\??\C:\Cygwin\home\lavr\test\dir.lnk)
   46   86397 [main] find 5420 symlink_info::check: 0xC0000034 = NtCreateFile (\??\C:\Cygwin\home\lavr\test\dir.exe.lnk)
   26   86423 [main] find 5420 symlink_info::check: 0xC0000034 = NtQueryInformationFile (\??\C:\Cygwin\home\lavr\test\dir.exe.lnk)
   27   86450 [main] find 5420 symlink_info::check: 0 = symlink.check(C:\Cygwin\home\lavr\test\dir, 0x289450) (0x3000A)
   30   86480 [main] find 5420 mount_info::conv_to_win32_path: conv_to_win32_path (/home/lavr/test)
   28   86508 [main] find 5420 set_flags: flags: binary (0x2)
   25   86533 [main] find 5420 mount_info::conv_to_win32_path: src_path /home/lavr/test, dst C:\Cygwin\home\lavr\test, flags 0x3000A, rc 0
   55   86588 [main] find 5420 symlink_info::check: 0x0 = NtCreateFile (\??\C:\Cygwin\home\lavr\test)
   35   86623 [main] find 5420 symlink_info::check: not a symlink
   42   86665 [main] find 5420 symlink_info::check: 0 = symlink.check(C:\Cygwin\home\lavr\test, 0x289450) (0x3000A)
   26   86691 [main] find 5420 path_conv::check: this->path(C:\Cygwin\home\lavr\test\dir), has_acls(1)
   32   86723 [main] find 5420 build_fh_pc: fh 0x61275D10, dev 0xC3
   30   86753 [main] find 5420 __set_errno: int open(const char*, int, ...):1369 setting errno 20
   28   86781 [main] find 5420 open: -1 = open(/home/lavr/test/dir, 0x30C000), errno 20

Clearly, find would be happy to see ENOENT there (and it's actually what should have
been flagged in the absence of the directory after its removal, as ENOTDIR is
not applicable in such case).

Thanks,

Anton Lavrentiev
Contractor NIH/NLM/NCBI


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list