mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Portability: Use fcntl instead of flock
- POSIX file locking mechanism, eliminating platform-specific code.
This commit is contained in:
parent
71fef9f22f
commit
c346cf9395
6 changed files with 25 additions and 76 deletions
35
src/util.cpp
35
src/util.cpp
|
@ -42,7 +42,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -228,40 +227,6 @@ const std::string uuid ()
|
|||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// On Solaris no flock function exists.
|
||||
#ifdef SOLARIS
|
||||
int flock (int fd, int operation)
|
||||
{
|
||||
struct flock fl;
|
||||
|
||||
switch (operation & ~LOCK_NB)
|
||||
{
|
||||
case LOCK_SH:
|
||||
fl.l_type = F_RDLCK;
|
||||
break;
|
||||
|
||||
case LOCK_EX:
|
||||
fl.l_type = F_WRLCK;
|
||||
break;
|
||||
|
||||
case LOCK_UN:
|
||||
fl.l_type = F_UNLCK;
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fl.l_whence = 0;
|
||||
fl.l_start = 0;
|
||||
fl.l_len = 0;
|
||||
|
||||
return fcntl (fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &fl);
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Run a binary with args, capturing output.
|
||||
int execute (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue