Why would rmdir /s fail but still delete the innermost subdirectory?

1

I had a directory structure (src/...) created by Cygwin's 7za.exe. From a command prompt I ran rmdir /s /q src.

This resulted in error messages (paraphrasing as my DOS shell has long since overflowed):

Cannot delete src/test/unit/geom

The directory is not empty

Browsing to src/test/unit/geom showed that it was indeed empty, so I ran the same rmdir command again. Same error, but pointing at src/test/unit instead. And my Explorer window that was showing the absence of contents in src/test/unit/geom dropped down to src/test/unit.

Three rmdir executions later, it is fully gone.

This is Windows 7 and set CYGWIN=nontsec had been run. I believe this has been the source of build problems for some time now, but until now I hadn't identified the culprit.

What can I do to avoid this in the future? If it happens again, what should I look for in terms of identifying corrupt aspects of the directory structure?

Raven

Posted 2011-10-31T22:09:36.940

Reputation: 1 388

Question was closed 2016-02-01T20:30:23.760

I am mystified. I tried this and it didn't work, then I tried the exact same command and it did work. Buggy? Circumstances unknown mitigating the behavior? First, it only removed a whole subdirectory tree provided all the directories are empty (apart from having subfolders--) in other words it did not work when files were in the folder. Then it did work with files in the folder. ?! – r_alex_hall – 2016-02-01T16:03:51.753

What command interpreter was running as this "command prompt"? Microsoft's CMD? bash? TCC? It's not a "DOS shell", by the way. DOS has nothing to do with it; and you aren't running DOS.

– JdeBP – 2011-11-01T00:09:23.500

@JdeBP DOS shell on Windows 7 == CMD – Raven – 2011-11-01T16:55:31.573

2No, that's not a DOS shell. It's a Win32 program. DOS has nothing to do with it, as I said. Moreover: I already know what comes in the box. That's not the question that you were asked. But I also know that you're the sort of person who installs things like Cygwin. So for the second time: What command interpreter were you using? – JdeBP – 2011-11-01T19:09:19.463

Answers

1

If you can reproduce the problem, try using Sysinternals ProcMon (or FileMon) to see what's happening under the covers. It's been a while since I've look at this stuff but IIRC, cygwin performs some fancy steps to replicate Unix semantics and the results are not always perfect.

jdigital

Posted 2011-10-31T22:09:36.940

Reputation: 861

No repro since I started looking hard at the issue, but if I ever get one I'm confident ProcMon will be the answer. – Raven – 2012-01-07T01:42:49.343