I am trying to update glibc to 2.34 for my system, then I came across the issue.
Test code:
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <semaphore.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
if (2 != argc)
{
printf("%s name\n", argv[0]);
return -1;
}
int flags = O_CREAT;
const char* _name = argv[1];
sem_t* _newsem = sem_open(_name, flags, 0666, 0);
if (SEM_FAILED == _newsem)
{
perror("sem_open fail");
return -1;
}
sem_close(_newsem);
return 0;
}
Run:
# ./a.out /tmp
sem_open fail: Read-only file system
I have known that the glibc-2.34 have some changes on sem_open(): https://lwn.net/Articles/864920/
but I have no idea to fix the issue? If you have any suggestions ,pls help me.