Exclusive file lock
This commit is contained in:
parent
c407afe435
commit
b1db9d30cf
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"unistd.h": "c"
|
"unistd.h": "c",
|
||||||
|
"mman.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,6 +5,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
|
#include <sys/file.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
struct sus_File_impl{
|
struct sus_File_impl{
|
||||||
@ -21,6 +22,8 @@ sus_File sus_fileOpenInMem(char * fileName, unsigned long parameter) {
|
|||||||
int fd = open(fileName, flags, S_IRWXU);
|
int fd = open(fileName, flags, S_IRWXU);
|
||||||
if(fd == -1) return NULL;
|
if(fd == -1) return NULL;
|
||||||
|
|
||||||
|
flock(fd, LOCK_EX);
|
||||||
|
|
||||||
struct stat info;
|
struct stat info;
|
||||||
if(stat(fileName, &info)) {
|
if(stat(fileName, &info)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user