mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 14:26:00 +01:00
On GNU Hurd use flock instead of fcntl.
Furthermore we need to open the file for writing if we want to lock it for writing.
This commit is contained in:
parent
3ae7e5d7b6
commit
87ef40e399
1 changed files with 7 additions and 2 deletions
|
@ -21,11 +21,16 @@
|
|||
#define KEY_SCALE "scale"
|
||||
#define KEY_ROTATE "rotate"
|
||||
|
||||
#ifdef __GNU__
|
||||
#include <sys/file.h>
|
||||
#define file_lock_set(fd, cmd) flock(fd, cmd)
|
||||
#else
|
||||
#define file_lock_set(fd, cmd) \
|
||||
{ \
|
||||
struct flock lock = { .l_type = cmd, .l_start = 0, .l_whence = SEEK_SET, .l_len = 0}; \
|
||||
fcntl(fd, F_SETLK, lock); \
|
||||
fcntl(fd, F_SETLK, lock, NULL); \
|
||||
}
|
||||
#endif
|
||||
|
||||
static void zathura_database_interface_init(ZathuraDatabaseInterface* iface);
|
||||
|
||||
|
@ -441,7 +446,7 @@ zathura_db_read_key_file_from_file(const char* path)
|
|||
}
|
||||
|
||||
/* open file */
|
||||
FILE* file = fopen(path, "r");
|
||||
FILE* file = fopen(path, "rw");
|
||||
if (file == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue