BSD syscall#137
svc · unix #137
rmdir
Removes an empty directory by path.
Prototype
int rmdir(char *path);Returns: int
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| path | char | - |
Version history
| XNU tag | macOS | # |
|---|---|---|
| xnu-1456.1.26 | macOS 10.6 Snow Leopard | 137 |
| xnu-1486.2.11 | — | 137 |
| xnu-1504.15.3 | — | 137 |
| xnu-1504.3.12 | — | 137 |
| xnu-1504.7.4 | — | 137 |
| xnu-1504.9.17 | — | 137 |
| xnu-1504.9.26 | — | 137 |
| xnu-1504.9.37 | — | 137 |
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