What does errno 39 (ENOTEMPTY) mean?

 
Could be also:
ConstantTypeOS
ERROR_HANDLE_DISK_FULLWin32 errorWindows
KERN_LOCK_UNSTABLEKern returnMac
ippStsEvenMedianWeightIntel Ipp StatusAny
EDESTADDRREQerrnoMac
EL3HLTerrnoSolaris
ENOLCKerrnoWindows
RDR_FILE_SYSTEMBugCheck CodeWindows
Previous Next
ENAMETOOLONG EDESTADDRREQ

ENOTEMPTY

Why an apparently empty directory can still fail

ENOTEMPTY usually appears when rmdir(), a directory rename, or a replacement operation needs the destination to contain no entries other than the conventional dot entries. Hidden names, temporary files, concurrent writers, and cleanup jobs can all make a directory nonempty after an application has already checked it.

The error is therefore often a race, not proof that the user-facing listing was wrong. A mount point or directory currently protected by another filesystem rule may produce a different error such as EBUSY, so the exact system call and path state matter. Recursive deletion is not an automatic remedy: it can remove data created by another actor after the initial check.

How to resolve it safely

  • Enumerate the directory immediately before the operation and include hidden entries in the diagnostic record.
  • Identify writers, unpackers, editors, and cleanup tasks that may create names concurrently.
  • Use a single owner or a namespace-level lock when lifecycle operations must be serialized.
  • For a replacement deploy, create a new versioned directory and switch a stable pointer only after contents are complete.

References


Looking for a different code? Search another status or error code.