Browse Source

Merge pull request #2052 from nonlin-lin-chaos-order-etc-etal/openssl

Add fcntl to actually lock pidfile on Android
pull/2053/head
orignal 9 months ago committed by GitHub
parent
commit
2d2469c23d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      daemon/UnixDaemon.cpp

11
daemon/UnixDaemon.cpp

@ -162,12 +162,21 @@ namespace i2p @@ -162,12 +162,21 @@ namespace i2p
#ifndef ANDROID
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));
std::cerr << "i2pd: Could not lock pid file " << pidfile << ": " << strerror(errno) << std::endl;
return false;
}
#endif
char pid[10];
sprintf(pid, "%d\n", getpid());
ftruncate(pidFH, 0);

Loading…
Cancel
Save