Skip to content
BSD syscall#137

svc · unix #137

rmdir

Removes an empty directory by path.

Prototype

int rmdir(char *path);

Returns: int

Arguments

NameTypeDirDescription
pathchar-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard137
xnu-1486.2.11137
xnu-1504.15.3137
xnu-1504.3.12137
xnu-1504.7.4137
xnu-1504.9.17137
xnu-1504.9.26137
xnu-1504.9.37137

Notes

Returns ENOTEMPTY if any entry beyond `.` and `..` exists. On APFS the directory may have hidden extended attributes that count as non-empty; use xattr -l to investigate. Concurrent rmdir attempts are serialised by the namei lock on the parent.

Detection

ES emits ES_EVENT_TYPE_NOTIFY_UNLINK with the removed vnode; syscall::rmdir:entry shows the path.

Related APIs

mkdirunlinkrenameatunlinkat