mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-10 01:10:32 +00:00
Add fcntl to actually lock pidfile on Android
This commit is contained in:
parent
26fac94d05
commit
8e80a8b06f
@ -162,12 +162,21 @@ namespace i2p
|
|||||||
|
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
if (lockf(pidFH, F_TLOCK, 0) != 0)
|
if (lockf(pidFH, F_TLOCK, 0) != 0)
|
||||||
|
#else
|
||||||
|
struct flock fl;
|
||||||
|
fl.l_len = 0;
|
||||||
|
fl.l_type = F_WRLCK;
|
||||||
|
fl.l_whence = SEEK_SET;
|
||||||
|
fl.l_start = 0;
|
||||||
|
|
||||||
|
if (fcntl(pidFH, F_SETLK, &fl) != 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
LogPrint(eLogError, "Daemon: Could not lock pid file ", pidfile, ": ", strerror(errno));
|
LogPrint(eLogError, "Daemon: Could not lock pid file ", pidfile, ": ", strerror(errno));
|
||||||
std::cerr << "i2pd: Could not lock pid file " << pidfile << ": " << strerror(errno) << std::endl;
|
std::cerr << "i2pd: Could not lock pid file " << pidfile << ": " << strerror(errno) << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
char pid[10];
|
char pid[10];
|
||||||
sprintf(pid, "%d\n", getpid());
|
sprintf(pid, "%d\n", getpid());
|
||||||
ftruncate(pidFH, 0);
|
ftruncate(pidFH, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user