mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-17 04:50:57 +08:00
Simplified fdpair reset after fork
This commit is contained in:
parent
2be70dca1a
commit
51f8571933
@ -181,8 +181,7 @@ int zmq::signaler_t::wait (int timeout_)
|
||||
return -1;
|
||||
}
|
||||
#ifdef HAVE_FORK
|
||||
if (unlikely(pid != getpid()))
|
||||
{
|
||||
if (unlikely(pid != getpid())) {
|
||||
// we have forked and the file descriptor is closed. Emulate an interupt
|
||||
// response.
|
||||
//printf("Child process %d signaler_t::wait returning simulating interrupt #2\n", getpid());
|
||||
@ -263,23 +262,10 @@ void zmq::signaler_t::recv ()
|
||||
#ifdef HAVE_FORK
|
||||
void zmq::signaler_t::forked()
|
||||
{
|
||||
int oldr = r;
|
||||
#if !defined ZMQ_HAVE_EVENTFD
|
||||
int oldw = w;
|
||||
#endif
|
||||
|
||||
// replace the file descriptors created in the parent with new
|
||||
// ones, and close the inherited ones
|
||||
// Close file descriptors created in the parent and create new pair
|
||||
close (r);
|
||||
close (w);
|
||||
make_fdpair (&r, &w);
|
||||
#if defined ZMQ_HAVE_EVENTFD
|
||||
int rc = close (oldr);
|
||||
errno_assert (rc == 0);
|
||||
#else
|
||||
int rc = close (oldw);
|
||||
errno_assert (rc == 0);
|
||||
rc = close (oldr);
|
||||
errno_assert (rc == 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user