define some _POSIX_* macros that were omitted; required for XSI conformance
[musl] / src / mman / shm_unlink.c
1 #include <sys/mman.h>
2 #include <errno.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5 #include <string.h>
6
7 int shm_unlink(const char *name)
8 {
9         int dir, ret;
10
11         while (*name == '/') name++;
12         if (strchr(name, '/')) {
13                 errno = EINVAL;
14                 return -1;
15         }
16
17         if ((dir = open("/dev/shm", O_DIRECTORY|O_RDONLY)) < 0) return -1;
18         ret = unlinkat(dir, name, 0);
19         close(dir);
20         return ret;
21 }