forked from Mirrors/openclonk
linux: add CLOEXEC flag to miscellaneous calls
parent
3755a36dd1
commit
1929e8d779
|
@ -850,7 +850,11 @@ C4NetIOTCP::Peer *C4NetIOTCP::Accept(SOCKET nsock, const addr_t &ConnectAddr) //
|
||||||
if (nsock == INVALID_SOCKET)
|
if (nsock == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
// accept from listener
|
// accept from listener
|
||||||
|
#ifdef __linux__
|
||||||
|
if ((nsock = ::accept4(lsock, reinterpret_cast<sockaddr *>(&addr), &iAddrSize, SOCK_CLOEXEC)) == INVALID_SOCKET)
|
||||||
|
#else
|
||||||
if ((nsock = ::accept(lsock, reinterpret_cast<sockaddr *>(&addr), &iAddrSize)) == INVALID_SOCKET)
|
if ((nsock = ::accept(lsock, reinterpret_cast<sockaddr *>(&addr), &iAddrSize)) == INVALID_SOCKET)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// set error
|
// set error
|
||||||
SetError("socket accept failed", true);
|
SetError("socket accept failed", true);
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
|
|
||||||
C4FileMonitor::C4FileMonitor(ChangeNotify pCallback): fStarted(false), pCallback(pCallback)
|
C4FileMonitor::C4FileMonitor(ChangeNotify pCallback): fStarted(false), pCallback(pCallback)
|
||||||
{
|
{
|
||||||
fd = inotify_init();
|
fd = inotify_init1(IN_CLOEXEC);
|
||||||
|
if (fd == -1) fd = inotify_init();
|
||||||
if (fd == -1) LogF("inotify_init %s", strerror(errno));
|
if (fd == -1) LogF("inotify_init %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -555,12 +555,9 @@ bool CStdNotifyProc::CheckAndReset()
|
||||||
|
|
||||||
CStdNotifyProc::CStdNotifyProc()
|
CStdNotifyProc::CStdNotifyProc()
|
||||||
{
|
{
|
||||||
// FIXME: Once linux version 2.6.27 is required, use EFD_NONBLOCK and EFD_CLOEXEC
|
fds[0] = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
|
||||||
fds[0] = eventfd(0, 0);
|
|
||||||
if (fds[0] == -1)
|
if (fds[0] == -1)
|
||||||
Fail("eventfd failed");
|
Fail("eventfd failed");
|
||||||
fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | O_NONBLOCK);
|
|
||||||
fcntl(fds[0], F_SETFD, FD_CLOEXEC);
|
|
||||||
}
|
}
|
||||||
CStdNotifyProc::~CStdNotifyProc()
|
CStdNotifyProc::~CStdNotifyProc()
|
||||||
{
|
{
|
||||||
|
@ -689,12 +686,9 @@ bool CStdMultimediaTimerProc::CheckAndReset()
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
CStdMultimediaTimerProc::CStdMultimediaTimerProc(uint32_t iDelay)
|
CStdMultimediaTimerProc::CStdMultimediaTimerProc(uint32_t iDelay)
|
||||||
{
|
{
|
||||||
// FIXME: Once linux version 2.6.27 is required, use TFD_NONBLOCK and TFD_CLOEXEC
|
fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||||
fd = timerfd_create(CLOCK_MONOTONIC, 0);
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
Log("timerfd_create failed");
|
Log("timerfd_create failed");
|
||||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
|
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
|
||||||
SetDelay(iDelay);
|
SetDelay(iDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue