Skip to content

Commit

Permalink
Merge pull request #1680 from chrisburr/python-macos-fork
Browse files Browse the repository at this point in the history
Don't abort if it looks like we're about to fork
  • Loading branch information
simonmichal committed Apr 20, 2022
2 parents cbe1b62 + 2714cdb commit 1f765a4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/XrdSys/XrdSysIOEventsPollKQ.icc
Expand Up @@ -224,7 +224,15 @@ void XrdSys::IOEvents::PollKQ::Begin(XrdSysSemaphore *syncsem,
else if (numpolled < 0)
{int rc = errno;
cerr <<"KQ: " <<XrdSysE2T(rc) <<" polling for events" <<endl;
abort();
//--------------------------------------------------------------
// If we are in a child process and the poll file descriptor
// has been closed, there is an immense chance the fork will be
// followed by an exec, in which case we don't want to abort
//--------------------------------------------------------------
if( rc == EBADF && parentPID != getpid() )
return;
else
abort();
}
else for (int i = 0; i < numpolled; i++)
{if ((cP = (Channel *)pollTab[i].udata)) Dispatch(cP, i);
Expand Down
10 changes: 9 additions & 1 deletion src/XrdSys/XrdSysIOEventsPollPoll.icc
Expand Up @@ -199,7 +199,15 @@ void XrdSys::IOEvents::PollPoll::Begin(XrdSysSemaphore *syncsem,
else if (numpolled < 0)
{int rc = errno;
cerr <<"EPoll: " <<XrdSysE2T(rc) <<" polling for events" <<endl;
abort();
//--------------------------------------------------------------
// If we are in a child process and the poll file descriptor
// has been closed, there is an immense chance the fork will be
// followed by an exec, in which case we don't want to abort
//--------------------------------------------------------------
if( rc == EBADF && parentPID != getpid() )
return;
else
abort();
}
else{if (pollTab[0].revents) numpolled--;
for (i = 1; i < num2poll && numpolled; i++)
Expand Down
10 changes: 9 additions & 1 deletion src/XrdSys/XrdSysIOEventsPollPort.icc
Expand Up @@ -197,7 +197,15 @@ void XrdSys::IOEvents::PollPort::Begin(XrdSysSemaphore *syncsem,
{if (errno == ETIME || !errno) CbkTMO();
else {int rc = errno;
cerr <<"PollP: " <<XrdSysE2T(rc) <<" polling for events" <<endl;
abort();
//--------------------------------------------------------------
// If we are in a child process and the poll file descriptor
// has been closed, there is an immense chance the fork will be
// followed by an exec, in which case we don't want to abort
//--------------------------------------------------------------
if( rc == EBADF && parentPID != getpid() )
return;
else
abort();
}
}
for (int i = 0; i < (int)numpolled; i++)
Expand Down

0 comments on commit 1f765a4

Please sign in to comment.