Refactor: extract code to make an fd non-clocking into a function.
Simply extract part of the code from evtloopunix.cpp into a reusable wxPipe::MakeNonBlocking() function to be able to reuse it elsewhere. See #12636. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -52,6 +52,16 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// switch the given end of the pipe to non-blocking IO
|
||||
bool MakeNonBlocking(Direction which)
|
||||
{
|
||||
const int flags = fcntl(m_fds[which], F_GETFL, 0);
|
||||
if ( flags == -1 )
|
||||
return false;
|
||||
|
||||
return fcntl(m_fds[which], F_SETFL, flags | O_NONBLOCK) == 0;
|
||||
}
|
||||
|
||||
// return TRUE if we were created successfully
|
||||
bool IsOk() const { return m_fds[Read] != INVALID_FD; }
|
||||
|
||||
|
Reference in New Issue
Block a user