What does errno 17 (EEXIST) mean?

 
Could be also:
ConstantTypeOS
ERROR_NOT_SAME_DEVICEWin32 errorWindows
KERN_INVALID_RIGHTKern returnMac
ippStsUnderflowIntel Ipp StatusAny
THREAD_NOT_MUTEX_OWNERBugCheck CodeWindows
Previous Next
EBUSY EXDEV

EEXIST

Why this can be a normal race outcome

EEXIST means that an API was asked to create an object only if the destination name was absent, but the name was already present. The classic file case is open() with both O_CREAT and O_EXCL; link creation and newer no-replace rename operations use the same idea. The error can be an expected result when several workers try to claim the same name.

It is often a sign that the program correctly used an atomic create-or-fail primitive instead of performing a separate “does it exist?” check. The latter check introduces a race: another process can create the object between the check and the create request.

How to handle it correctly

  • Decide whether an existing object means success, a conflict, or a request to generate a new unique name.
  • Inspect the object before treating it as equivalent; the same name may belong to another tenant, job, or version.
  • Keep creation atomic. Do not replace O_EXCL with a check-then-create sequence.
  • For concurrent workers, record the creator identity and use an explicit claim/lease protocol when a name alone is not enough.

References


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